Last Updated: February 25, 2016
· bdcribbs

Please, oh please, use git fetch


When working on a project you usually synchronize your code by pulling it several times a day. What you might not know is that "git pull" is two things at once. It is a "git fetch" followed by a "git merge". If you do not understand the difference, you should ask your co-workers who understand Git better than you to explain. If you still do not understand, you should only fetch, and then ask someone on your team to help you understand.

5 Responses
Add your response


:+1: I always use git fetch now, for it shows you new branches, new tags and so on.

over 1 year ago ·

I use git fetch as part of my workflow to keep track of several remote contributors work across several branches.

This is more an opinion piece that talks down to people who might not be aware of or sufficiently familiar with Git and DVC to understand why they should be using the command. Using an example and clarifying why and what they should be doing would more useful as a Protip. :)

over 1 year ago ·

I say use git pull if you want to but one should know how to git fetch + git merge do and when they may be better than pull. :)

over 1 year ago ·

Saying "Don't use X, but ask somebody else why" is no tip, but a waste of time. Anyway, the tip is not completely right too: There is nothing wrong with git pull, as long as you know, what you are doing (ask your coworker ;)). It is somehow ironic, that I've found the real answer on coderwall: https://coderwall.com/p/tnoiug

In short: Setup git to perform a rebase instead of a merge after pull for you, instead of doing it on your own manually every time.

over 1 year ago ·

"There is nothing wrong with git pull, as long as you know, what you are doing (ask your coworker ;))."

But it is for that reason I can't recommend 'pull' to novices, it makes them do the wrong thing, and impedes them from understanding the git 'model'.

It is initially more convenient. But convenience at the price of doing the wrong thing is a steep penalty.

over 1 year ago ·