7 ms·
Build Git – Learn Git
- together_us 13y agoI love the idea! This is a really cool way to learn anything, then, for that matter, I guess. Thank you.
- traviscj 13y agoBINGO. I actually try to do this before job interviews: build a dumb version of one of their big products. I'm not even talking about something as sophisticated as this git project, I mean "build a dumb version".
- pkmishra 13y agoReally cool. I loved it.
- joelgrus 13y agoThis is a great way to understand Git, thanks!
- grabeh 13y agoI suspect you may already be aware, but if not then here's a related project https://github.com/creationix/js-git https://github.com/creationix/js-git. Lest you misunderstand, I'm not saying you should stop development, I just thought it might be of interest!
- chinchang 13y agoYeah, knew about it.
- masklinn 13y agoOr, in a different language, https://github.com/jelmer/dulwich https://github.com/jelmer/dulwich
- fleon 13y agoFrom what it seems, I believe the objectives of both the projects differ greatly. js-git attempts to replicate the functionality of git entirely using Javascript, whereas this one is to make people learn and understand git using programming paradigms.
- graywh 13y agoThis reminds me of a talk by Jim Wierich I heard years ago where he pretends to design a new vcs in order to explain how git works. I'm not sure if a full recording can be found anywhere other than buying it from Pragmatic Programmers. https://www.youtube.com/watch?v=bBQJP6D8aGY https://www.youtube.com/watch?v=bBQJP6D8aGY
- jimweirich 13y agoThe talk is only available as a screencast from the Pragmatic Programmers, but the slides are freely available on my github account (https://github.com/jimweirich/presentation_source_control https://github.com/jimweirich/presentation_source_control). I use this talk as an introduction to any Git Immersion workshops that I run (see also http://gitimmersion.com/ http://gitimmersion.com/)
- unwind 13y agoThis is nice. One pet peeve is that (as far as I know, I'm really not an expert) Git repos don't actually have names. The first thing the article does when implementing them is to give them names, which I thought was a bit jarring. I actually think the namelessness of the repos is one of the things that are unexpectedly cool about Git.
- chinchang 13y agoProbably right.I think I gave them naming keeping mind Github repos have name...maybe :)
- jbranchaud 13y agoTutorial looks awesome. It would be helpful if you would mention from the beginning that you will be implementing in JavaScript before reaching the code snippets.
- chinchang 13y agoValid point. Will update the article. Thanks.
- esteb_li 13y agoVery nice. Basic reimplementation is always useful to visualize abstract concept like Git. Git can be hard to new comers, as it's not always obvious what commit/branch/push does. Thank you
- vaidik 13y agoAwesome work as always chinchang!
- jheriko 13y agoimplementing git is an interesting approach to learning it. i generally support this kind of stuff - however I think that this starts out implementing a source control solution rather than git in particular and its a shame that it follows git so closely later down the line in that regard (but completely understandable given the aim). solving the problems for yourself you can get some insight into why git is the way it is (and svn, p4, hg, everyone else...)
- ahuth 13y agoI'm pretty sure the point of the article is to learn about how to use git by implementing its basic functionality. The point isn't to implement how git works. On a side note, I'm always amazed when someone implements things that are complicated to me in a really understandable ways.
- drrotmos 13y agoA nice concept, but it doesn't really have much to do with Git. It's just another SCM system, and the concepts are just as applicable to e.g. Mercurial as Git. There are enough differences from Git to make it quite incompatible (named repository, incremented commit IDs, single parents et c.).
- chinchang 13y agoThe point is to implement gradually. For example, in the concepts covered in part 1, multiple parents was not required, hence it was left. It should make sense to the reader why something was implemented and why it does what it does. Its concepts might apply to other VCS. But that is immaterial, Git is what we are trying to understand here.
- evmar 13y agoI also attempted to understand git better by implementing it, but my (Haskell, uncompleted, abandonded) implementation was more concerned with getting all the on-disk representations right: http://evan-tech.livejournal.com/254793.html http://evan-tech.livejournal.com/254793.html
- jonhmchan 13y agoThis is an excellent resource. On Bento, I have so many tutorials and walkthroughs on the basics of Git (it's a very readily accessible teaching opportunity) that it's gotten somewhat unwieldy. In many instances, some of the material is very base, and I've been looking for something more thorough without being too specialized. This gives an excellent walkthrough of how Git works, but not only that, serves an excellent exercise on JavaScript. Bravo.
- xrd 13y agoBrilliantly done. Thank you.
- holoiii 13y agoVery cool. I would like to see other utilities or tools explained in this way. Keep up the good work!
- Crito 13y agoA related good way of learning Git is to check out/checkout the very first commits of git made using git. I found the shear lack of code that a working system could be made of to be enlightening.
- bhaisaab 13y agoGreat post by an awesome humble programmer :) (NB: he's a friend who also happens to be a colleague at work)
- eklavya 13y agonice nick Bhaiji :P
- twice 13y agoThank you, it's a very nice tutorial and I have not thought about this before (concept of trying to implement something you want to learn and get a better understanding of).
- talles 13y agoSweet. Should have take quite some time to format the whole tutorial.
- chinchang 13y agoIt sure did. Though, there is a lot of code, so its always fun :)
- Cogito 13y agoI appreciate the work that has gone into this, and think it is a great starting point for an interesting tutorial about git. My concern is that the tutorial ignores or discards ideas essential to how git works, and what makes git different to other version control systems. As other comments have said, this is showing 'just another SCM system' without illuminating the design decisions that make git different. For example, in git it is extremely important that commit objects have a unique identifier for any given working directory, history, and commit meta-data. Without this guarantee the distributed architecture of git is (almost) impossible to implement. In the commit section the tutorial states: a simple Commit class would have ... a change containing the snapshot of change made. Understanding how a change is actually stored is beyond the scope of this implementation. This terminology is misleading at best, and skips over a very important concept in how git actually works. The phrase 'snapshot of change made' is misleading, as a commit doesn't contain any explicit information about changes made. Instead, the staged files in the working directory are saved into a 'blob' store, a tree structure is created to represent the directory structure, and a reference to the tree is saved in the commit object. I understand that all this is outside the scope of the tutorial, however an outline of how commits work is important information for anyone trying to understand how git works. For example, the storage format is the primary reason operations in git are so fast. Again, I like the tutorial, but if it wants to teach about git, as opposed to other version control systems, it needs to ensure the key git concepts are maintained.
- chromejs10 13y agoI 100% agree. It's always great to try to implement complicated things, but it misses the point if what you're implementing is nothing like the original system. You aren't learning how Git works if you do it that way are instead just mimicking API names
- chinchang 13y agoReiterating on my point again, the aim of this project is not to replicate Git. JS-Git (https://github.com/creationix/js-git https://github.com/creationix/js-git) does that.Here I am trying to code basic concepts relaxing complex stuff so that reader can focus & visualize more abstract concepts. I have tried to bring in concepts as and when wanted instead of just overloading the reader with complex stuff all at once.
- codez 13y agoIt's a cool concept but like other comments say it overlooks a lot of the things that make git, git. Best way to learn? use it! Maybe just create a dummy repo and go from there with it. Maybe use the GUI tools until you're comfortable with the command line. For me personally, it was command line first. If you aren't sure about something with git, googling it will pretty much always throw out your answer.
- andrewaylett 13y agoI'm not sure I quite agree. Use it, yes, but if you're using Git as a black box then you're much more likely to be frustrated by it than if you understand what's going on under the hood. I tend to point people at "Git from the bottom up"[0] -- it gives people the understanding they need to work out the effect they require, from which they can work out which set of commands will get them there. [0] http://ftp.newartisans.com/pub/git.from.bottom.up.pdf http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
- codez 13y agoMost people will not be using advanced functions though and if people generally understand how version control works, I don't think git is super hard to pick up and learning whilst doing is most effective for me. I'm sure most people are probably aware of : http://try.github.io/ http://try.github.io/ which is a cool little resource for learning git.
- rajeshpillai 13y agoGreat work and keep continuing with the series. I understand this is not exactly the real git's inner working, but this series of articles may lead some other coder or hacker or other inquisitive mind to stitch together the missing part. That's the beauty of sharing!