git push
git push
Command is used to update the local branch, pushed to the remote host. Its format git pull
command similar.
$ git push <远程主机名> <本地分支名>:<远程分支名>
Note: here: before and after must be no spaces.
Note that the order of the branch push wording is <Origin>: <dest>, it git pull
is <remote branch>: <local branch>, and git push
the <local branch>: <remote branch>.
If you omit the remote branch name, it said it would push the local branch with the presence of "trace relationship" remote branch (usually both of the same name), if the remote branch does not exist, it will be new.
$ git push origin master
Represents the above command, the local master
branch pushed origin
host master
branch. If the latter does not exist, it is new.
If you omit the local branch name, then delete the specified remote branch, because this is equivalent to pushing an empty local branches to remote branches.
$ git push origin :master
# 等同于
$ git push origin --delete master
The above command means to delete origin
the host master
branch.
If there is tracing the relationship between branch and remote branch currently, the local branch and a remote branch can be omitted.
$ git push origin
Represents the above command, the current will push the branch origin
corresponding to the branch host.
If the current track has only one branch branch, then the host name can be omitted.
$ git push
If the current relationship between the presence of trace branches and multiple hosts, you can use the -u
option to specify a default host so that you can later use without any parameters git push
.
$ git push -u origin master
The above command will local master
branch pushed to origin
the host, while designated origin
as a default host, the latter can be used without any use git push
of.