The difference between 'git pull' and 'git fetch'
What is the difference between a
git pull and
To put it plainly, a
git pull performs a
git fetch followed by a
git pull to update a local branch with its remote version. When we pull, Git will automatically attempt a merge without allowing us to review the changes.
With many branches and developers, we can run into merge conflicts quite frequently.
From the documentation for
In its default mode,
git pullis shorthand for
git fetchfollowed by
git merge FETCH_HEAD.
git fetch to tell us of any changes in the remote branch since our last pull. It does not merge the changes with our current branch but rather simply gathers the new commits from the target branch and stores them in our local repository.
This is especially useful to keep our repositories updated while working on a breaking change.
To integrate these commits into our branch, we can use
git merge separately.