Zach
Zach

Reputation: 650

How to push to a specific branch on bitbucket using git

I understand that the command

git push <url>

is what you're supposed to use to push but as I understand it that just pushes to the master branch. How do I push to different branches on this project. Can someone explain how this works because I don't understand it?

Upvotes: 2

Views: 23125

Answers (2)

Michael Millar
Michael Millar

Reputation: 1614

git checkout -b branch1

creates & checks out a branch branch1

do your work, git add, git commit etc

git push origin branch1 pushes to the branch called branch1

Best quick guide is here http://rogerdudler.github.io/git-guide/

Upvotes: 4

abhiarora
abhiarora

Reputation: 10450

You can specify the name of the branch along with the command. Like,

git push origin your_branch

It will push your_branch branch in your local system to your_branch in the remote machine. But if you want to push a branch called your_local_branch to a remote branch named your_remote_branch, then you should type -

git push origin your_remote_branch:your_local_branch.

Upvotes: 10

Related Questions