Synopsis
Description
Integrate changes from a remote repository into the current branch. First,git pull runs git fetch with the same arguments (excluding merge options) to fetch remote branch(es). Then it decides which remote branch to integrate: if you run git pull with no arguments this defaults to the upstream for the current branch. Then it integrates that branch into the current branch.
There are 4 main options for integrating the remote branch:
git pull --ff-onlywill only do “fast-forward” updates: it fails if your local branch has diverged from the remote branch. This is the default.git pull --rebaserunsgit rebasegit pull --no-rebaserunsgit mergegit pull --squashrunsgit merge --squash
pull.rebase, pull.squash, or pull.ff with your preferred behaviour.
Common Usage
Pull from the default remote
Update the remote-tracking branches for the repository you cloned from, then merge one of them into your current branch:This is equivalent to
git pull origin in most cases. Normally the branch merged in is the HEAD of the remote repository, but the choice is determined by the branch.<name>.remote and branch.<name>.merge options.Pull a specific branch
Merge into the current branch the remote branch This leaves a copy of
next:next temporarily in FETCH_HEAD, and updates the remote-tracking branch origin/next.Options
Repository and Refspec
Repository and Refspec
<repository>The “remote” repository to pull from. This can be either a URL or the name of a remote. Defaults to the configured upstream for the current branch, or origin.<refspec>Which branch or other reference(s) to fetch and integrate into the current branch, for example main in git pull origin main. Defaults to the configured upstream for the current branch. This can be a branch, tag, or other collection of reference(s).Output Options
Output Options
-q, --quietThis is passed to both underlying git-fetch to squelch reporting of during transfer, and underlying git-merge to squelch output during merging.-v, --verbosePass --verbose to git-fetch and git-merge.Integration Options
Integration Options
-r, --rebase[=(true|merges|false|interactive)]true- rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes. This is the default.merges- rebase usinggit rebase --rebase-mergesso that the local merge commits are included in the rebasefalse- merge the upstream branch into the current branchinteractive- enable the interactive mode of rebase
--no-rebaseThis is shorthand for --rebase=false.--squashRun git merge --squash to integrate changes.Submodule Options
Submodule Options
--recurse-submodules[=(yes|on-demand|no)]--no-recurse-submodulesThis option controls if new commits of populated submodules should be fetched, and if the working trees of active submodules should be updated too.If the checkout is done via rebase, local submodule commits are rebased as well. If the update is done via merge, the submodule conflicts are resolved and checked out.Examples
Basic pull from default remote
HEAD of the remote repository, but the choice is determined by the branch.<name>.remote and branch.<name>.merge options.
Pull and merge a specific remote branch
next temporarily in FETCH_HEAD, and updates the remote-tracking branch origin/next. The same can be done by invoking fetch and merge:
Pull with rebase
Default Behavior
Often people usegit pull without giving any parameter. Traditionally, this has been equivalent to saying git pull origin. However, when configuration branch.<name>.remote is present while on branch <name>, that value is used instead of origin.
Related Commands
git fetch
Download objects and refs from another repository
git merge
Join two or more development histories together
git rebase
Reapply commits on top of another base tip
git config
Get and set repository or global options
