I'm following this tutorial on pushing an existing project to Bitbucket, and it mentions using the command git push -u origin --all. How does this command differ from git push origin master?
1 Answer
git push origin masterpushes your current branch up to themasterbranch onorigin.git push -u origin -allpushes all branches to origin. The-uoption sets up your local branches to track the remote branches. This essentially establishes a link between your local branch, and the branch on the remote repository. Without doing this if you switch to one of these branches and do agit pushyou'll be greeted with an error messagefatal: The current branch <branch-name> has no upstream branch.You can check the branch link by commandgit branch -vv.
Summary: git push -u origin -all pushes all branches to origin, git push origin master pushes your current branch up to the master branch on origin.
1 Comment
snwflk
Middle ground is
git push -u origin master, which pushes & tracks only a single branch.
git help push