git push
will push your code to your existing upstream. Depending on the push configuration, it will either push code from you current branch (default in Git 2.x) or from all branches (default in Git 1.x).
When working with git, it can be handy to have multiple remote repositories. To specify a remote repository to push to, just append its name to the command.
git push origin
To push to a specific branch, say feature_x
:
git push origin feature_x
Unless the branch you are working on originally comes from a remote repository, simply using git push
won't work the first time. You must perform the following command to tell git to push the current branch to a specific remote/branch combination
git push --set-upstream origin master
Here, master
is the branch name on the remote origin
. You can use -u
as a shorthand for --set-upstream
.
To push to a repository that you haven't made yet, or is empty:
https://github.com/USERNAME/REPO_NAME.git
git remote add origin URL
git remote -v
git push origin master
Your code should now be on GitHub
For more information view Adding a remote repository
Push code means that git will analyze the differences of your local commits and remote and send them to be written on the upstream. When push succeeds, your local repository and remote repository are synchronized and other users can see your commits.
For more details on the concepts of "upstream" and "downstream", see Remarks.