DEV Community

Git Gud at git

Nic Hartley on February 21, 2019

Show of hands, everyone, who knows git? Not just the standard git pull / git commit / git push arcanery that you go through to magically make your...
Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

I love this! As you add support for more of Git's features, this will become very useful. Not to mention, it's fun! I'd like to be able to refer people to this as a training tool someday.

I'd also like to see this gain some ability to work with "push/pull" to drive home the point of remote vs. local.

Collapse
 
nichartley profile image
Nic Hartley

Push/pull is definitely on the table, but maybe a little further down. A bunch of the code is centered around there being just one tree with just one head, one set of branches, etc., and it'd take a decently big refactor to make it more abstracted. It's definitely not impossible, though, and it'll come eventually.

Collapse
 
bobopd profile image
Pradyumna Das

You guys could take a look at learngitbranching.js.org/. I have used this to learn a couple of years ago. It's quite mature

Collapse
 
nichartley profile image
Nic Hartley • Edited

Looks cool! I like Git Gud better, personally; it has a much cleaner look, but there are definitely some lessons to learn from that. It also gives me some ideas for how to implement more difficult commands like cherry-pick. Thanks!

Collapse
 
moopet profile image
Ben Sinclair

It looks interesting, but I'm put off by the way it's themed to look like an old Mac, and that it's completely non-obvious that you can scroll bits of it (I suppose that is keeping the Mac philosophy of having an unintuitive UI, but still...)

Collapse
 
pauguillamon profile image
PauGuillamon

I was going to comment the same! Learned a lot with learngitbranching when I was learning git about 4 years ago! I always recommend it.

For the post, it's still and very interesting project, congrats to the authors!

Collapse
 
stecman profile image
Stephen Holdaway • Edited

Neat! I've had a similar idea kicking around for a few years to illustrate how rebasing works with animation, but haven't got around to implementing it.

An interesting approach might be a live visualisation in a browser of an actual repository on disk, since that would mean you can focus on the visualisation without having to emulate git's command line.

Collapse
 
nichartley profile image
Nic Hartley

While that'd certainly be cool, it'd be much more work. This way I can emulate the tree in very little memory and without needing to access the filesystem at all, which can be difficult.

I do also plan to add rebase, actually, to Git Gud -- I'm just swamped by work right now. Being a student can be tough, haha.

Plus, there's always git log --graph --all or gitk --all :)

Collapse
 
kensixx profile image
Ken Flake

I love it! It illustrates how git works, and especially for noobs like me, I'm getting a kind of close-to-actual representation that you can't see elsewhere (or am I just not searching too far?) Hahaha!

Collapse
 
johncip profile image
jmc • Edited

This is a really cool idea, and a Git playground would be useful for the after-school CS program I'm part of. I'm also kind of in awe that you're using C++ for this.

But I have to say that the way branches are modeled here doesn't really line up with how I've come to see them. While it can be sometimes useful to picture them as "lanes," branching in Git only made sense to me when I started picturing them as just pointers to a commit.

(If commits are lanes, what does it look like when a commit is part of multiple branches?)

It's deceptively simple, and for a long time I didn't get that I didn't get it. I had come to Git from Subversion, where branches actually are lanes. Eventually I read Think Like a Git and Git's model finally clicked. Suddenly I was able to branch, merge, cherry-pick and rebase with zero surprises.

It boils down to this: Git has commits, which are full snapshots, and pointers to commits, which give you a way to name them. During a new commit, tags (one type of pointer) stay on the previous commit, and branches (the other kind of pointer) may move to the new one. Only one actually does -- and git calls that the "checked out" branch.

Collapse
 
nichartley profile image
Nic Hartley

Yup, branches are pointers to commits, but there are two issues with drawing them like that:

  1. It makes it hard to tell which commits are part of which branches (you need to manually follow them back from the head, and even then it's hard to tell where one branch 'splits' from another)
  2. It makes it much harder to render.

Honestly, the latter was the biggest thing; we tried to get labels pointing at the branch head, but because of all the edge cases it was surprisingly hard to get it happening without making something look weird.

Collapse
 
jcast profile image
Jason Castellano

I love this idea! This would be an excellent playground for Git noobs, especially those that come from a more traditional VCS, like SVN. Great job!

Collapse
 
_hellorashid profile image
Rashid Aziz

This really awesome stuff! I spent a whole couple hours this morning trying to learn git beyond just add+commit+push, and I'm still confused by it all! Really helpful and looking forward to when you add more features!

Collapse
 
araslanove profile image
Araslanov Eugene

Nice!

Collapse
 
aldoreno profile image
Leonardo Situmorang

Awesome stuff! Am so gonna use this on my next Git workshop/class!

Collapse
 
entrptaher profile image
Md Abu Taher • Edited

Did you play "Hollow Knight"? Git gud is a popular term there. I played 💯 hours and still cannot best the boss.

Collapse
 
nichartley profile image
Nic Hartley • Edited

It's popular across a lot of gaming, not just Hollow Knight; the gaming term is where we got the inspiration for the name.