Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy. This is the same as
git fetch ＜remote＞ followed by
git merge origin/＜current-branch＞.
Similar to the default invocation, fetches the remote content but does not create a new merge commit.
Same as the previous pull Instead of using
git merge to integrate the remote branch with the local one, use
Gives verbose output during a pull which displays the content being downloaded and the merge details.
You can think of
git pull as Git's version of
svn update. It’s an easy way to synchronize your local repository with upstream changes. The following diagram explains each step of the pulling process.
You start out thinking your repository is synchronized, but then
git fetch reveals that origin's version of main has progressed since you last checked it. Then
git merge immediately integrates the remote main into the local one.
git pull is one of many commands that claim the responsibility of 'syncing' remote content. The
git remote command is used to specify what remote endpoints the syncing commands will operate on. The
git push command is used to upload content to a remote repository.
git fetch command can be confused with
git pull. They are both used to download remote content. An important safety distinction can be made between
git pull and
git fetch can be considered the "safe" option whereas,
git pull can be considered unsafe.
git fetch will download the remote content and not alter the state of the local repository. Alternatively,
git pull will download remote content and immediately attempt to change the local state to match that content. This may unintentionally cause the local repository to get in a conflicted state.
--rebase option can be used to ensure a linear history by preventing unnecessary merge commits. Many developers prefer rebasing over merging, since it’s like saying, "I want to put my changes on top of what everybody else has done." In this sense, using
git pull with the
--rebase flag is even more like
svn update than a plain
In fact, pulling with
--rebase is such a common workflow that there is a dedicated configuration option for it:
After running that command, all
git pull commands will integrate via
git rebase instead of
The following examples demonstrate how to use
git pull in common scenarios:
Executing the default invocation of
git pull will is equivalent to
git fetch origin HEAD and
git merge HEAD where
HEAD is ref pointing to the current branch.