What is the difference between 'git pull' and 'git fetch'?

0 like 0 dislike
15 views

What are the differences between git pull and git fetch?

by (550 points) | 15 views

1 Answer

0 like 0 dislike

In the simplest terms, git pull does a git fetch followed by a git merge.

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/.

This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).

git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

Git documentation – git pull:

In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

by (1.2k points)
110,608 questions
257,186 answers
0 comments
1,117 users