git push to remote branch

Rubyalto picture Rubyalto · Jun 8, 2011 · Viewed 67.2k times · Source

Folks,

I had cloned a repo. I created a branch out of it to work on a feature by issuing the following command:

git branch fix78

then I worked on that branch by

git checkout fix78

I continued to make commits to this local branch. Now I wanted to push this to the repo and hence I issued the following command:

git push origin master:fix78

I viewed the repo from a web browser and saw that a new branch called fix78 was created on the repo. But it did not have any of my commits that I had made.

What am I doing wrong here? This is what I am trying to achieve:

There is a repo(master(trunk in the SVN lingo)), now when I am working on a feature I want to create a local branch of it and then I also want to check in this branch to the repo(so that other team members can see what I am working on), then I want my local branch to be in sync with this remote branch that I create.

Any help/feedback would be totally awesome.

Thanks.

Answer

rlc picture rlc · Jun 8, 2011

git push origin master:fix78 pushes the local master to a remote branch called fix78. You wanted to push the local branch fix78, which has the same syntax but without the master:

You can fix it by doing git push origin :fix78 to delete the remote branch and then git push origin fix78 to push your local branch to the remote repo.