Git pull
Usage:
Git pull < remote host name > < remote branch name >:< local branch name >
Common wording:
1. Full path
Git pull Origin Master:master
Retrieve the master branch of the remote host and merge with the local master branch
2. Omit local Branch
Git pull Origin Master
Retrieves the master branch of the remote host name origin and merges with the local current branch
Essentially, this equates to git fetch, then git merge.
Git fetch origin
git merge Origin/master
3. Omit the remote branch name
In some cases, Git automatically creates a tracking relationship (tracking) between the local branch and the remote branch. For example, in Git clone, all local branches default to the remote host with the same name branch, establish a tracking relationship, that is, the local master branch automatically "track" Origin/master branch.
Git also allows you to manually establish tracking relationships.
Git branch--set-upstream Dev origin/dev
The above command specifies that the DEV branch tracks the Origin/dev branch.
If the current branch has a tracing relationship with the remote branch, git pull can omit the remote branch name.
$ GIT pull origin
The above command indicates that the local current branch is automatically merged with the corresponding Origin host "Trace branch" (Remote-tracking Branch).
4. Omit Host name
If the current branch has only one trace branch, even the remote host name can be omitted.
Git pull
git push
Usage:
GIT push < remote host name > < local branch name >:< Remote Branch name >
To push < local branch > to the remote Branch < remote host name >
Common wording:
1. Omit the remote branch
Git push Origin Master
Push the local master branch to the remote host name Origin's master branch (created if it does not exist)
2. Omit local Branch
git push origin:master
Sending an empty local branch to the remote Maser branch is actually removing the remote branch equivalent to the GIT push Origin--delete Master
3. Omit local branch and remote branch
Git push origin
If there is a tracking relationship between the local branch and the remote branch, both the local branch and the remote branch can be omitted
(If an error occurs, you may need to establish a tracking relationship with git push--set-upstream origin dev)
Leave a question: How do I check this tracking relationship? git remote show origin (view details of remote host)
4 omitting the remote host name
git push
Only associated with a remote host name such as: Origin
If the current branch has a tracking relationship with multiple hosts, you can use the-u option to specify a default host so that you can use Git push without any parameters later.
$ Git push-u Origin Master
The above command pushes the local master branch to the origin host, specifying origin as the default host, and then using git push without any parameters.
git push without any parameters pushes only the current branch by default, which is called simple mode. In addition, there is a matching method that pushes all local branches that have corresponding remote branches. Prior to Git version 2.0, the default is to use the matching method, which now defaults to Simple mode. If you want to modify this setting, you can use the git config command.
git config--global push.default simple
This article is from the "Tridewah operation and maintenance work Road" blog, please be sure to keep this source http://cuidehua.blog.51cto.com/5449828/1813928
git remote operation git pull git push