git pull Command
The git pull command is used to fetch code from a remote repository and merge it into the local version.
git pull is essentially a shorthand for git fetch
followed by git merge FETCH_HEAD
.
The command format is as follows:
git pull <remote host name> <remote branch name>:<local branch name>
Example
Update operation:
$ git pull
$ git pull origin
Fetch the master branch from the origin remote and merge it into the local brantest branch.
git pull origin master:brantest
If the remote branch is to be merged with the current branch, the part after the colon can be omitted.
git pull origin master
The above command indicates fetching the origin/master branch and merging it into the local brantest branch.
The above pull operation expressed as a fetch would be:
Taking my https://github.com/tianqixin/tutorialpro-git-test as an example, fetching from the remote and merging into the local branch.
$ git remote -v # View information
origin https://github.com/tianqixin/tutorialpro-git-test (fetch)
origin https://github.com/tianqixin/tutorialpro-git-test (push)
$ git pull origin master
From https://github.com/tianqixin/tutorialpro-git-test
* branch master -> FETCH_HEAD
Already up to date.
The above command indicates fetching the origin/master branch and merging it into the local master branch.