Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

git push command

git push command

Git Basic OperationsGit Basic Operations


git push The command is used to upload local branch versions to the remote and merge them.

The command format is as follows:

git push <远程主机名> <本地分支名>:<远程分支名>

If the local branch name is the same as the remote branch name, the colon can be omitted:

git push <远程主机名> <本地分支名>

Example

The following command pushes the local master branch to the master branch of the origin host.

$ git push origin master

Equivalent to:

$ git push origin master:master

If the local version differs from the remote version but you still want to force 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 of the origin host:

git push origin --delete master

Take my https://github.com/tianqixin/runoob-git-test As an example, add a file locally:


$ touch runoob-test.txt      # 添加文件
$ git add runoob-test.txt 
$ git commit -m "添加到远程"
master 69e702d] 添加到远程
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 runoob-test.txt

$ git push origin master    # 推送到 Github

Push the local master branch to the master branch of the origin host.

Returning to our Github repository, you can see the file has been committed:


Git Basic OperationsGit Basic Operations