Search code examples
gitversion-controlpush

git push to specific branch


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 run the 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...

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

Solution

  • git push origin amd_qlp_tester will work for you. If you just type git push, then the remote of the current branch is the default value.

    Syntax of push looks like this - git push <remote> <branch>. If you look at your remote in .git/config file, you will see an entry [remote "origin"] which specifies url of the repository. So, in the first part of command you will tell Git where to find repository for this project, and then you just specify a branch.