Hacker News new | ask | show | jobs
by scarejunba 2596 days ago
Honest to god, I don't know how people who find `git` hard to use manage to write code. Everyone on the Internet acts like the concepts are impossible to grasp and it's like really easy to grok.

Honestly, it faded into the background of code from the beginning. I mean, I know "Forward-port local commits to the updated upstream head" means nothing to anyone not already familiar with `git rebase` but a practical mastery of the tool is very easy to achieve.

I honestly think this is a pedagogical lack. We tell everyone it's this complex thing and that they should be scared of rebase and the reflog and they believe it. Maybe if we didn't, it'd be easier.

9 comments

It's common for people teaching others how to use git to start off the lesson with some sort of disclaimer about git being really hard. I think this is a huge mistake. I suppose it's meant to prevent the student from feeling discouraged if they happen to struggle, but the student struggling with git is not a foregone conclusion. Such statements can demoralize the student before they even dive into it though. When you tell your student that git is hard, you are doing them a disservice.
I usually couch git intros with "git was designed for linux kernel developers to get their work done, specifically filesystem developers, specifically Linus, so a lot of things won't make sense unless you approach it from the mindset of the above. don't worry! that mindset is probably different to yours but you can learn a good approximation to it and then you'll be really good at reasoning about git"
Git being difficult has unfortunately become a meme, and like all memes, gets propagated irrespective of its truth value.

Like I get it, we all enjoy making fun of vi but imagine every thread about vi only filled with people harping about ":wq". It gets tiring real soon.

I think many believe that "this should be easy, just add commits and get versioning, voilà!" and thus never invest the time (what, 2 days max?) to actually dig in, try a few common scenarios on a dummy repo, before actually using it on a live project.

The truth is, it's not so easy a task to get versioning right and git does, people are not humble enough.

I agree. Usually if someone gives out a concrete change they'd make to improve git I can quickly point out a simple workflow it breaks because they have a mental model of a Github repo with a trunk and branches. Lots want to couple commit and push, but on this machine

  history|grep 'git commit'|wc -l 
is 20 times larger than

  history|grep 'git push'|wc -l
I know some people know git in depth but for me its a tool that shouldn't be main the focus of my work. It should work and get out of the way (which it does for basic workflows). Its when something unusual happens that it is a pain in the arse to use and requires far too much understanding in my opinion.
Most of OP's post isn't just the basic Git commands - it's super-user features that might help a novice who can do the basic add/commit/push/pull chain but doesn't even know you can revert in Git history, or make new branches.

Nothing shameful in someone sharing that knowledge to help a newcomer become a super-user faster.

Nothing against the post. It’s sharing tips. I’m talking about what the other commenters are talking about. The ‘difficulty’.

Reason I posted top-level is that it isn’t an indictment of any specific “this is hard” poster but of the general view. I don’t know when it started becoming this common belief but it’s not true.

Confess. You are the Git Hobgoblin masquerading as a human programmer.

http://stevelosh.com/blog/2013/04/git-koans/#the-hobgoblin

I refuse. I object to “git is hard”. I do not object to “the UX can be improved, perhaps significantly”. Other things that are easy but could have improved UX:

* Bart turnstiles: the green lit-up arrow doesn’t mean you can use the turnstile with your card. Only if that arrow is present and the Clipper reader has a green light on it can you use it. Not hard, really.

* Doors that you should push but have a handle: the presence of the handle implies a pull and yet you have to push. Hard? No.

* Applications which use a floppy disk icon for save. Not hard at all.

Honestly, I think the UI is like any tool. You learn it in a day and through use it gets so familiar you don’t even think about it. But many have complained about this and UIs are harder to evaluate, so I can easily admit I’m wrong here. The difficulty, though, that’s overstated. The absolute ease with which it came to me and to nearly everyone I know puts the lie to that.

My guess is that git is a supporting tool to the main task. As such, it's tempting to always search for the next solution for a git problem on StackOverflow, or wherever, rather than actually learning the concepts behind git.

If people _did_ learn those concepts, they wouldn't find it "impossible to grasp" and then it would be more appropriate to compare one's knowledge of git to their programming knowledge.

yes. If it is this hard to understand rebasing, how can there be understanding of other programming core concepts?
I was thinking if I would post what you did it would get downvoted but yeah, if you find git hard how or why are you writing code? That is surely a lot harder. Not sure why it is downvoted as sure it might not be a popular opinion but it seems to hold...
> if you find git hard how or why are you writing code? That is surely a lot harder.

So many things wrong with your premises...

How do you know every git user is writing code? Is git only for code now?

And in the code case... were you born knowing how to use git? Or were you forced to learn it before you wrote a single line of code? Or were you forced not to learn it until you were a pro coder? Is it difficult to fathom something landing between these extremes?

Thank you for posting. It helps to know that others, too, haven’t had this uphill slog just to use it. It just faded into the background right from the start.
I want to focus on code and not be wrestling with a version control system.
OK hot shot. Tell everyone here how you've never fucked up commands and had to blow out a repo and start over and how were all idiots for having done that.

It's a tool. Any tool can be confusing if the person isn't taught how to use it. Git requires teaching so there's a lot of room for misunderstanding.

> never fucked up commands and had to blow out a repo and start over

You never have to do this, because it's virtually impossible to screw up a git repo with git commands, to the point it can't be easily fixed. And I'll tell you why and how.

As you no doubt know, all commits in git are hashed. This means that you can't change a commit in any way, only ever add a new one. Neither can you insert a commit into an existing chain: you have to rewrite the whole chain with new commits.

As a consequence, if your `master` branch, for example, is pointing to commit `aa33bf`, there will be a unique chain of commits leading back to the original commit which can't be altered.

It doesn't matter if you cherry-pick, merge, rebase or dance the fandango...if you point `master` back to `aa33bf` it will look exactly the same as it did before.

You can usually find what the branch was pointing before with `git reflog`. But you were going to clone it from github again, right? So, `origin/master` is pointing to the right commit, and you can just reset it back to that (remember to first commit any random stuff in your working dir that you want to keep):

  git checkout master
  git reset --hard origin/master
And, obviously, you can do exactly the same with any other branches that have been messed up.

There you go. Now you too are a "git hot shot" and can wow your friends with your amazing skills. ;)

It's called sarcasm /s
Yes, I'm aware you were attempting sarcasm, but it wasn't very good, was it? I thought it would be kinder to ignore it and post something useful. The phrase you're looking for is, "thank you".

Cheers!

No hot shot either but that literally never happened. It happened with cvs but not with git.

And confusing can be and imho in this case is, something else than difficult.

I'm not the hot shot. The hot shots are all the kids from Berkeley and Stanford who figure this shit out as interns while supposedly fully-trained engineers with all the knowledge of data structures that should come with that think this shit is too hard.

I think I'd be completely unsurprised to see an intern successfully use `rerere` on a longer project of theirs.

I know of teenagers who happily use git because nobody ever told them they were supposed to consider it hard.
This is exactly what I’ve seen. Thank you for validating that viewpoint. Without being told they’re going to find it hard, they just rapidly build a model of how to interact with the tool and how it improves their life.