8 ms·
The Elements of Git
- Stampo00 5y agoI'm a huge fan of git education. From a computer science standpoint, git is very clever but not particularly hard to understand. From a usage standpoint, although it's gotten better over the years, I still wouldn't call it user-friendly. I'd like to see more competing implementations out there. I'd like to see better git libraries for application support. I'd like to see libraries that support alternatives to flat file repo representations.
- bloopernova 5y agoI kind of view git like vim, awk, or Emacs. It has a complex set of features, and it takes time and practice to learn to use them sufficiently well. The quality of the introductory documentation has gotten better over the years, thank goodness. I know a great many developers who are terrified of git, and stick to the couple of commands they get taught by the team lead.
- everybodyknows 5y agoFor anyone new to git, or puzzled by its fundamental structure, I recommend starting with this: https://medium.com/girl-writes-code/git-is-a-directed-acyclic-graph-and-what-the-heck-does-that-mean-b6c8dec65059 https://medium.com/girl-writes-code/git-is-a-directed-acycli... While reading the Medium post, it may be helpful to bear in mind that arcs shown in the drawings — called “pointers” in the text — are exactly hashes to git.
- olvy0 5y agoI must I found this, personally, to be the most clear and concise explanation of git's internals than the tens of other explanations I've read the last couple of years. Kudos to whoever wrote this.
- nerdponx 5y agoI think all sophisticated frameworks need a document like this. What are the basic components of the system, what purpose do they serve, and how do they interact?
- tomasreimers 5y agoUnderstanding how Git internals can actually be useful as more than just to build intuition or as an academic exercise! For example, where I work (https://graphite.dev https://graphite.dev) we use some of these plumbing commands to extend git to store additional information about pull requests. My teammate did a writeup of this here: https://dev.to/foster/how-to-use-native-git-as-a-key-value-store-1fgg https://dev.to/foster/how-to-use-native-git-as-a-key-value-s...
- operatorequals 5y agoI got pretty fed up with learning got from the internet when I had too (about 8 years ago). Every resource I could find was written in a way that only people that already knew could really understand. Now, that I finally feel good enough, that I can rely on what I know and finally in position to mentor others, I made what I feel was missing, a set of sandbox git repository challenges, with only real life examples [1] I met in professional repos. I hope the dark age of git education passes soon (and is already fading). [1]: https://github.com/operatorequals/git-course https://github.com/operatorequals/git-course
- iib 5y agoThis is exactly what I felt was missing as well. Git is the kind of "skill" you can only master on the job, doing lots of case studies, not just reading documentation and tutorials. There are lots of other programs like that, GDB for example, each with it's own challenge of sythesizing case studies. I hope this kind of learning continues, not only with git, but across other programs as well.
- dboreham 5y agoThis is a symptom of the extremely poor design of its user interface (conceptually, I mean, not how it looks), notwithstanding its origins in Linux royalty.
- wrycoder 5y agoThe secret is that git is, first and foremost, an on-disk data structure (hereafter "git repo"). It's very well-defined and documented, which means that anyone can write a new tool that processes a git repo. Go for it!
- ellyagg 5y agoGood idea, but I've already filled all available slots for working on projects with no upside for me or my company.
- 5y ago
- mynameismon 5y agoMy favourite video explaining Git: https://missing.csail.mit.edu/2020/version-control/ https://missing.csail.mit.edu/2020/version-control/ Explains nearly everything you need concisely and effectively, in about 20 minutes (the rest of it is primarily demonstration).
- tonetheman 5y agoGit is a circle jerk for programmers who would rather talk about work than actually do work.
- wtetzner 5y agoI don’t follow. I use git for real work all the time.
- phist_mcgee 5y agoWhat I don't understand, is why we need so many articles explaining git and its elements? It seems like these posts are very popular and occur frequently on HN. Either people love revising their knowledge on git, or as is my suspicion, git is a tricky and unintuitive piece of software. I'm a bit bewildered that there have been no so far successful efforts to condense/revise git into a more developer friendly experience from the outset (and that doesn't include writing more 'secrets of git' posts). Just an observation.
- 725686 5y agoI was lucky enough to learn git from the "git for ages 4 and up" from Michael Schwern: https://youtu.be/1ffBJ4sVUb4 https://youtu.be/1ffBJ4sVUb4
- mistrial9 5y agothis is my favorite too! brilliant
- sillysaurusx 5y agoI have a basic question: if git forwards its first argument to git-$arg, then how would you produce a list of all possible git commands? Is there something like ls, but for possible programs on your PATH? Or is there a way to just get a dump of all executables on the current PATH? Even still, it seems like you’d have to decide which of those programs to show first in the documentation. And to get a short description of each of them, you’d have to invoke them. I guess the solution is “use manpages,” but it’s kind of unsatisfying — I’d like to build something like git, but using CLI --help. EDIT: Seems ... strange. - https://github.com/git/git/blob/master/help.c#L260-L294 https://github.com/git/git/blob/master/help.c#L260-L294 - https://github.com/git/git/blob/master/command-list.txt https://github.com/git/git/blob/master/command-list.txt - https://github.com/git/git/blob/master/generate-cmdlist.sh https://github.com/git/git/blob/master/generate-cmdlist.sh I'm not sure `git help` supports the concept of adding third-party `git` commands as first-class citizens, but I'm still reading.
- mdaniel 5y ago"git help -a" specifically performs that same discovery process and lists what it finds (including aliases!), so one need not reinvent that wheel
- sillysaurusx 5y agoIt seems like `git help -a` doesn't allow third-party commands to have docstrings at all. It seems to call getenv("PATH"), then calls readdir on each folder, filters out any non-executables that aren't prefixed with "git-", and then lists those under the "External commands" category with no further help. I was hoping there was a way to attach a short help descriptor to each of the third-party commands. But the help descriptors seem to be hardcoded for the builtin commands, with no support for third party commands. Darn.
- Aeolun 5y agoKind of scary to execute all git- prefixed commands when you run ‘git help’. Maybe have a location where git stores descriptions for external commands?
- mistrial9 5y agowell you have to give credit to something so well-written and clear. I have read and listened to git knowledge like the rest here, and I have favorites. This exposition shows the actual files on disk, in trees, in a way I had never seen. The opening paragraphs emphasizing that the data structures are stable, while the tools are interoperable, may be written in other languages, and rely on the stable data structures, is also said here in a way I had never seen before. However, this is not the tutorial I would send anyone towards, as a user of git. The programming design logic is not enough to get better at the workflows. Mercifully, branching patterns in team projects are omitted entirely. enjoyable and glad to read this for a second or third layer to understanding git
- car 5y agoA couple of years ago I saw a video where Linus Thorvalds explains his creation, git, especially how everything is based on the SHA1 hash. It was very clear and understandable (at least to me), but I have not been able to find it again. Does anyone know which video I'm referring to?
- olvy0 5y agoMaybe this one? Tech Talk: Linus Torvalds on git (2007) "Linus Torvalds visits Google to share his thoughts on git, the source control management system he created two years ago." https://www.youtube.com/watch?v=4XpnKHJAok8 https://www.youtube.com/watch?v=4XpnKHJAok8
- car 5y agoThank you, but I don’t think this was it. The one I remember was more technical. However, I did discover Gilfoyle at 21:40 ;).
- nirvalt 5y agoI like to use GitGraph for vscode to have a better visual on everything going on in my repos