Live data from Hacker News

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

stackoverflow.com

21–29 of 29 posts

Re: What's the difference between 'git pull' and 'git fetch'?

#23

Just read git-pull.sh: it's a 300-line shell script. How much simpler does it get?

It gets simpler by someone telling in short what's the difference so you don't have to read and understand the code.

Just because you understands the basics of Git doesn't mean you can understand the language it was written in.

Re: What's the difference between 'git pull' and 'git fetch'?

#24
I feel like git has turned into the Perl of version control systems, in both the best and worst senses of the analogy. It's a system that was designed at a very low level but has grown organically from there, in directions dictated by how people use it (with Linus himself having an overwhelming influence here).

The real-world analogy is the probably apocryphal story about how some university/corporate campus/park whatever didn't put in paths, but instead waited a year to see where people walked and put in paths there. I first heard this story on John Siracusa's old podcast, but it's apparently been around for a long time. Some googling turned this up for yet another retelling: http://opensource.com/business/10/12/discovering-desire-line....

It's great because it really is insanely featureful compared to older VCS's, and it has absolutely enabled workflows that simply were not possible 10 years ago. On the other hand, the complexity and the inconsistencies and the TIMTOWTDIness of it all means that it is one more tool that you have to dedicate yourself to knowing inside out and thinking about all the time, as opposed to a tool that's more of a fire-and-forget thing that's easy to learn, easy to use, and never screws up (and doesn't give you enough rope to hang yourself).

Somewhere among git, Perl, Python, the Linux kernel, Mercurial, various Linux distros, various BSDs, and many many proprietary software projects, there is some really awesome classic book on software engineering waiting to be written, about the pros and cons of top-down vs. bottom-up design, having a BDFL vs. community-driven design and goals, user- vs. marketing- vs. developer-driven designs, etc.

Cathedral and the Bazaar doesn't count, it's way to shallow and opinionated about there being a right way to do everything. There really is no one true way to choose any of these approaches, and they all have their upsides and downsides. Maybe the best we can hope for is to be aware of these things and choose the best model on a per-project basis, and be able to adapt when that project's ideal model changes.

Re: What's the difference between 'git pull' and 'git fetch'?

#25
post #23

Just read git-pull.sh: it's a 300-line shell script. How much simpler does it get?

It gets simpler by someone telling in short what's the difference so you don't have to read and understand the code. Just because you understands the basics of Git doesn't mean you can understand the language it was written in.

Then being able to read basic code is a nice thing to aspire for, no?

Read and ask questions about what you don't understand.

Re: What's the difference between 'git pull' and 'git fetch'?

#26
post #23

Earlier quoted context omitted.

It gets simpler by someone telling in short what's the difference so you don't have to read and understand the code. Just because you understands the basics of Git doesn't mean you can understand the language it was written in.

Then being able to read basic code is a nice thing to aspire for, no? Read and ask questions about what you don't understand.

I know how to use drills, saws and other tools but never took them apart to see how they work inside.

Re: What's the difference between 'git pull' and 'git fetch'?

#27
I think what many people miss is that if you have a remote repository called, say, "origin", and a local branch synced with it called, say, "master", then there's a behind-the-scenes local branch called "origin/master". This third branch is what your local git repository knows about the remote branch.

    [ master ] -------------- [origin/master | master]
     remote                           local
With this model in mind the difference is pretty clear. `git fetch` pulls down all the new stuff from origin and updates origin/master but leaves your local master untouched. You can then merge origin/master into your local master to bring it up to date. `git pull` just does both steps: pull down the remote data into origin/whatever, and then merge origin/whatever into whatever.

    master   |    origin/master    | master
      ----------------->
      git fetch

      ----------------->--------------->
      git pull

Re: What's the difference between 'git pull' and 'git fetch'?

#28
When I see people say git is/is not complicated, I think that doesn't quite capture the problem. Git, like the set of chess moves, is simple. But git, like playing chess without being able to see the chessboard, puts a big cognitive load on users that many users think isn't necessary.

Moreover, that analogy might approach illustrating the problem, but is still unsatisfying. Unlike, say, Eclipse, where one can readily sum up how Eclipse fails at being a well behaved GUI - it offers to do things that will fail and are nonsensical - git is, on the one hand, a lot better designed and it provides more value than Eclipse, and on the other hand git is even more baffling to beginners.

I want to see what's happening. I want to see what's going on at every accessible point in the workflow of every project I am working on. I want to see the results of actions. I want to be presented with all and only the sensible actions in ways that are discoverable. I do not want a lame fake "GUI" that is just dialogs pasted on a CLI.

Re: What's the difference between 'git pull' and 'git fetch'?

#29
My OS is public domain, not Linux. No GPL code, losers.

God says... prolonged shrunk cutting generally Justina evenly Jerusalem Husband succeed storing lethargy fruitful partners drank wrap forethought umm transgressors overspreading rightly tumultuousness officers infirmity exercised sink contentious usually blessest affection luxuriousness distractedly S unteach phrases outward 'Gainst four mock spent Lamentable now thraldom pride Finland begannest consecrateth unexplained anon boils issue blotted amazing unsung_hero

Post reply on HN