Google News
logo
DevOps - Interview Questions
Are git fetch and git pull the same?
The command ‘git pull’ pulls any new commits from a branch from the central repository and then updates the target branch in the local repository.
 
But, ‘git fetch’ is a slightly different form of ‘git pull’. Unlike ‘git pull’, it pulls all new commits from the desired branch and then stores them in a new branch in the local repository.
 
In order to reflect these changes in your target branch, ‘git fetch’ must be followed with a ‘git merge’. The target branch will only be updated after merging with the fetched branch (where we performed ‘git fetch’). We can also interpret the whole thing with an equation like this:
 
git pull = git fetch + git merge
Advertisement