
You can see that in the output above, the changes were downloaded from the remote master and then merged using fast-forward method into the local master branch. Remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Remote: Compressing objects: 100% (3/3), done. Remote: Counting objects: 100% (3/3), done. The git pull command downloads from the remote repository to the local repository and automatically merges those changes into the current branch. When you are ready to merge, simply run: $ git mergeġ file changed, 7 insertions(+), 7 deletions(-) Now let’s see the list of commits that are in remote develop but not in local. Let’s switch to develop branch and do git fetch.

It will merge changes from the remote branch into local. Once you have reviewed the changes and are ready to merge, you can switch back to the master branch and run git merge.

After doing a fetch, if you want to check out what has changed, you can do: You’ll need to run git branch -a to see all local and remote branches. A remote tracking branch is a local copy (or mirror) of a remote branch, e.g. You may be thinking where are the changes are stored after a fetch since they are not merged into the working file? The answer is that they are stored in your local repository in what is called remote tracking branches. Because it doesn’t change your working directory or the staging area, it is entirely safe, and you can run it as often as you want. It downloads fresh changes that other developers have pushed to the remote repo since the last fetch and allows you to review and merge manually at a later time using git merge.

git fetch explained in detailĪs we’ve seen, git fetch only downloads latest changes into the local repository, and does not merge into the current branch. I have covered the main difference between git fetch and get pull above. Here’s a diagram to illustrate the difference between git fetch and git pull. One important thing to keep in mind is that it will merge only into the current working branch. It doesn’t give you a chance to review the changes before merging, and as a consequence, ‘merge conflicts’ can and do occur. Git pull in contrast not only downloads the latest data, but it also automatically merges it into your current branch and updates the working files automatically.
