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

git pull command

git pull command

Git Basic OperationsGit Basic Operations


git pull The command is used to fetch code from a remote and merge it with the local version.

git pull It is actually shorthand for git fetch and git merge: first fetch the latest commit records from the remote repository, then merge those commit records into your current branch.

The command format is as follows:

git pull [远程仓库名] [分支名]

Example

Update operation:

$ git pull
$ git pull origin

Pull the master branch from the remote host origin and merge it with the local brantest branch.

git pull origin master:brantest

If the remote branch is merged with the current branch, the part after the colon can be omitted.

git pull origin master

The above command means fetch the origin/master branch, then merge it with the local brantest branch.

The above pull operation expressed with fetch is:

Take my https://github.com/tianqixin/runoob-git-test as an example, load from remote and merge into the local branch.


$ git remote -v  # 查看信息
origin    https://github.com/tianqixin/runoob-git-test (fetch)
origin    https://github.com/tianqixin/runoob-git-test (push)

$ git pull origin master
From https://github.com/tianqixin/runoob-git-test
 * branch            master     -> FETCH_HEAD
Already up to date.

The above command means fetch the origin/master branch, then merge it with the local master branch.


Git Basic OperationsGit Basic Operations