git push to specific branch

code_fodder picture code_fodder · Oct 3, 2013 · Viewed 215.3k times · Source

Even after reading this question: git-push-current-branch, I am still having difficulty figuring out how I should write my git push command. As mentioned in the question link, it's not clear from the documentation.

I would like to use my 'real world' example. Following is what I see when I do a git status command on the top level of my branch:

On branch amd_qlp_tester

Your branch is ahead of 'origin/amd_qlp_tester' by 5 commits.

etc...

So my branch name is amd_qlp_tester but it was "branched" off from the main branch (if I have the terms wrong it's because of my SVN background). But then there is also the name `origin/amd_qlp_testser'

So how do I phrase my push command?

Is it any of the following:

git push origin/amd_qlp_tester
git push origin amd_qlp_tester
git push amd_qlp_tester
git push origin
git push

Answer

Imranmadbar picture Imranmadbar · Jun 12, 2018

If your Local branch and remote branch is the same name then you can just do it:

git push origin branchName

When your local and remote branch name is different then you can just do it:

git push origin localBranchName:remoteBranchName