git push Command
The git push command is used to upload local branch commits to a remote repository and merge them.
The command format is as follows:
git push <remote host name> <local branch name>:<remote branch name>
git push <remote host name> <local branch name>
Example
The following command pushes the local master branch to the master branch of the origin host.
$ git push origin master
Which is equivalent to:
$ git push origin master:master
If there are differences between the local and remote versions but you want to force the push, you can use the --force parameter:
git push --force origin master
To delete a branch on the host, you can use the --delete parameter. The following command deletes the master branch on the origin host:
git push origin --delete master
Taking my https://github.com/tianqixin/tutorialpro-git-test as an example, adding a file locally:
$ touch tutorialpro-test.txt # Add file
$ git add tutorialpro-test.txt
$ git commit -m "Add to remote"
master 69e702d] Add to remote
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tutorialpro-test.txt
$ git push origin master # Push to Github
Pushes the local master branch to the master branch of the origin host.
Returning to our Github repository, you can see that the file has been committed: