DEV Community

Cover image for Quick-fix git - resources to debug commits
Laís Carvalho
Laís Carvalho

Posted on • Updated on

Quick-fix git - resources to debug commits

If you have a dev account you probably know git. The most used Version Control System ever! Lab or Hub, raise your hand who never had a frustrating crisis while handling this bad-being (a gender-neutral reference to Bad Boys).

Recently, I had a 5 days fight with the system. Which culminated on Twitter breakdown, that later brought on TONS of good advice.

This post aims to reference the solid advice and add some more useful stuff I've learned while researching. You know, keeping it for posterity. In any case, here is the thread.

Debug pushes

  1. "Have you tried turning off and on again?"
    The git equivalent to it is the HARD resetting, that rewinds your repo to a specified commit. You can also delete the local copy and start fresh from a new clone. You'd be surprised how many people have this as the go to solution. Think "the print statement of git debugging".
    image
    Source: xkcd.com

  2. Compare/merge tool for easyly solving merge conflicts
    macOS users can try Kaleidoscope and Linux ones might prefer Meld, which also works on Windows.
    These tools help visualising the commit history of a repository and might be useful on debug cases. I have not tried just yet but the tip seems to be solid.

  3. Git history on the go
    I had no idea about the git log --graph command that shows your commit history on a graph. A bit of a confusing UI, so why not use a tool for it? Meet gitg, the GUI client for git repos. Worth a read.

  4. When in doubt? RESEARCH!
    It is silly to say this to you, fellow dev but when in doubt, Google it! Among the places with useful information I've found this blogpost on How to UNDO (almost) anything with git and the lifesaver Oh Shit, Git!?! that easily suggests code snippets to sort out your bellyache.

The golden rule

Finally, git will give you no white hairs (I found my first one 2 days ago, still on my 20s! #cry) if you learn that mofo inside out and back to front. How? Read the damn Pro Git book. Doubly recommended, it seems to be the basic milestone of git knowledge. You're welcome.

More learning resources?

  • Watch James Powell's talk at PyGotham on building a git client from scratch. Some lightning coding, for your delight.
  • Play with this visualy interactive website to learn git through a sandbox. A sort of virtual Golden Beads Montessori equivalent for learning commits effectivelly. Definetely a keeper!

Still struggling? Maybe a cry would help.

Got more suggestions? Drop them in the comment box below and let's have a chat!

Peace, yo!

Top comments (0)