by NelsonMinar · 11y ago · 0 comments
"You decide to bring in some more code from the public repo. Here is a 6000 word essay on what rebase means."
"You try to look at an old version of the code. Suddenly you are in ‘detached HEAD’ state. The End."
I love git, but simple intros like this hide all the confusing complexity and awkward UI that quickly comes to the forefront when using git for everyday work.
Which has the effect of (a) making them fear Git, (b) making them feel like they'll never figure it out, (c) and convincing them that they're always on the verge of losing data. I've literally had students at the start of my course refer to Git as "that system that makes me lose files."
Once I teach people about Git's objects and data structures, things suddenly become much more obvious to these people. Git becomes less of a mystery.
I'm not saying that Git is easy for people to understand or use, because it isn't. It has a steep learning curve -- one which I think is worth the effort. But I think that it does a disservice to Git newbies to try to summarize all of Git's functionality in a short essay, and then proclaim, "See? There's not that much to learn here!"
To be very effective and safe using git, you really do need to understand a bit about its inner workings. I find that to be a big weakness of the tool, and it continues to surprise me that it's become as popular as it has. I personally like git a lot, and find it to be very powerful, but it took time and an interest in deep learning to get there.
I can certainly understand that most people might want a simple VCS that's easy to use and makes it difficult to screw up. Git is not that VCS, by any means.
I might start to teach courses online at some point, but I'm right now so busy with in-person classes in Israel and China (with a bit in Europe probably happening soon) that I haven't had a chance to consider it. But hmm, maybe...
Meanwhile, see my above reply with some suggested resources to learn about and understand Git. I hope that they'll help.
[1]: https://codewords.recurse.com/issues/two/git-from-the-inside...
[1]: https://www.dropbox.com/sh/quumaubjftxik1u/AAD15CT1UrNyOuYSx...
I personally think git is simple. That doesn't mean it's easy. The issues listed in the GP comment seem to me mostly social. I think the most common problems with git stem from a more general difficulty in working with a branching, asynchronously developed codebase.
About merges... I think rebase is ridiculously overused, and people should use merges more. Clearly a feature branch littered with spurious merges is bad, but often it seems that this is taken simply to mean that merges are bad, and I get the impression that people go to ridiculous lengths with rebase etc. just to preserve an illusion of linear history even in cases where merging would be better.
Of these, my particular favorite is Michael Schwern’s “Git for ages 4 and up." Watch this, and suddenly Git will make a ton of sense. Jessica Kerr's talk about Git is a close second; it's remarkable for telling us about how Git thinks about things without showing any code.
One of my favorite tools to use in my Git course is this site:
http://www.wei-wang.com/ExplainGitWithD3/
which graphically shows what happens when you commit vs. change branches vs. rebase. Super cool stuff.
If you go through the two of these, and if you understand them, I think that you'll have about 90% of what you need to then re-read a Git introduction, and have things make sense.
Tinker toys really do make great graph visuals!
- The Git Book [1]
[0] http://tom.preston-werner.com/2009/05/19/the-git-parable.htm...
Alternatively, you could attend Recurse Center and sit through one of Mary's excellent git workshops. :)
Imagine you clone a repo. So your version is identical. You now add a couple more commits to master. Now, to make them identical again, all you have to do is upload the new commits, and then get his master branch to update to point to the latest one. Makes sense, right? That's a fast-forward.
Instead, what you do is merge your latest commit with the older commit two back, which creates a third commit with identical content to the previous one. That's silly, right? That's why fast-forward instead of merge.
> "You decide to bring in some more code from the public repo. Here is a 6000 word essay on what rebase means."
Rebase is when you take the content from a chain of commits, and make a completely new chain with that same content, just because it makes it look neater. You then change the branch from pointing at the head of the old chain to pointing at the head of the new. That's all it does. The old chain is still there until it's garbage collected a few weeks later (or you tag it to stop it disappearing).
> "You try to look at an old version of the code. Suddenly you are in ‘detached HEAD’ state. The End."
I'm not sure what the fear is here, so I'm not sure what to tell you. Create a test repository with a few commits and change the hashes below for real ones:
git checkout master # on master, whew
git checkout e34a53 # oh no, detached head
git checkout master # it's ok, back on master, whew
git checkout 343a34 # oh no, detached head
git checkout master # it's ok, back on master, whew
git checkout fe34ee # oh no, detached head
git checkout master # it's ok, back on master, whew
git checkout a567ed # oh no, detached head
git checkout master # it's ok, back on master, whew
Repeat until you're not panicking? :-) git checkout -B lastdeployed
to the end of your script would leave them happier!Then I gave up and went back to Mercurial. It does a much better job with subrepos, and I can actually use it without always consulting a hand-scrawled reference sheet for common tasks.
Mercurial's history rewriting is excellent. Do you know of `hg histedit`, `hg commit --amend`, `hg rebase`, `hg crecord --amend`?
If you're using Evolve, there's also `hg uncommit` and `hg amend`, amongst others:
https://www.youtube.com/watch?v=4OlDm3akbqg
(Demo begins around 9:10)
https://codewords.recurse.com/issues/two/git-from-the-inside...
ps: maybe it just fits my brain's inner working, I like to see every details before grasping the abstraction.
The thing about git is that the internals are sensible and cohesive, whereas the UI is a train wreck. This is the opposite of svn where the UI is simple, but the internals are a train wreck.
(And BTW my own simple subset is still simpler - no branches, for instance, as it helps people delay merges which IMO they tend to overdo even without branches; also helps people pull and think they "got the changes" without actually running the new stuff. Also, my own understanding of rebases, detached heads etc. etc. is minimal at best and I seriously dislike having to learn that sort of thing and having to keep it in mind.)
"You run 'git push --force'. You are likely to be eaten by a grue."