Git Basics: How to push your commits to remote repository?
As of now, as part of the Git Tutorial Series we learned about the changes, the commit to the staging area and viewing the working tree sta...- Article authored by Kunal Chowdhury on .
As of now, as part of the Git Tutorial Series we learned about the changes, the commit to the staging area and viewing the working tree sta...- Article authored by Kunal Chowdhury on .
As of now, as part of the Git Tutorial Series we learned about the changes, the commit to the staging area and viewing the working tree status. Once we are fine with the local branch changes, we need to push it to remote repository.
In this part of the tutorial, we will learn how to push these commits/changes to remote. Lets start discussing about the “git push” command and it’s various parameters.
I hope you are following my "Git Tutorial Series" and reading all the posts linked to that page. Don't forget to share it to your followers, friends and/or colleagues. They might be interested to read those too.
Last time (recently) we discussed about "git add", "git commit" and "git status" and today we are going to see and discuss on the topic/command that will help you to push your commits/changes to remote branch of your repository. The command to do this is: git push and it actually updates remote refs along with associated objects.
Here is the list of command parameters, which you will find interesting while working with Git repositories and Git branches.
Push changes of current branch to remote:
$ git push
$ git push <remote>
$ git push origin
$ git push <remote> <branch>
$ git push origin <branch>
Push changes to a specific branch:
$ git push origin <branch>
Push the current branch to the same name on remote:
$ git push origin HEAD
Push matching branches to origin:
$ git push origin :
Push the current branch to the remote ref matching master in the origin:
$ git push origin HEAD:master
Push the current branch forcefully to remote:
$ git push origin -f <branch>
$ git push origin --force <branch>
$ git push --all
$ git push <remote> <tag>
$ git push origin --tags
Push the tags to a remote branch:
$ git push origin --tags <branch>
Rename a remote branch by pushing local branch:
$ git push <remote> <localBranch>:<remoteBranch>
Remove remote branches that don’t have a local counterpart:
$ git push origin --prune
$ git push <remote> :<branch> # There's a space between <remote> and ':' (colon)
Add tracking refs for every branch that is up to date or pushed:
$ git push -u
$ git push --set-upstream
Was this post useful? If you came to this page by searching online about “git basics” or “git tutorials”, please have a look into my other blog posts. Subscribe to the RSS feed or the email newsletter to keep yourself updated.
Thank you for visiting our website!
We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.
We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.