DEV Community

Tawhid
Tawhid

Posted on • Edited on

Why Git is So Hard to Learn (and Why You Should Learn it Anyway)

To be clear: Git is confusing! Nobody picks up git and immediately feels like a wizard. If you're someone who has ever looked at your terminal and asked yourself what the hell "detached HEAD" means, you are definitely not alone.
But, Git is worth the pain. Once you get a handle on it, Git can be one of your most powerful tools as a developer. The important part is to know why it feels weird in the beginning.

Git Doesn’t Work Like Other Tools

Most tools do one job and do it simply. Git, on the other hand, is like a Swiss Army knife duct-taped to another Swiss Army knife. It tracks versions, coordinates collaboration, manages history, branches reality... and expects you to understand how all those parts fit together.
And unlike DropBox or Google Docs, Git does not give you a nice UI with who changed what. You get a command line, lots of arbitrary logs, and you figure out refs, trees, blobs, and commits.

So yeah. It's not you, it's Git.

The Mental Model Is The Difficult Part

Once you grasp the fundamentals, Git really starts to come together.

Think of Git as a really cool key-value store, because every commit is merely a point in time or a "snapshot" of your code, and that is precisely how Git will be storing these snapshots; as objects. The objects are related by the hashes, not by the file names. So, if you rename the file, it literally doesn't matter, because git doesn't care about names, it cares about content.

And branches? They’re just pointers. Tags? Also pointers. HEAD? Just a pointer to the pointer. Once you wrap your head around this, it stops feeling like magic and starts to feel like... well, still weird, but less scary.

You Will Mess Up

Everyone messes up in Git. You will push to the wrong branch. You will merge something by accident. You will panic when your files disappear after a reset.

But here’s the upside to it all: Git is pretty hard to break. You can usually revert almost anything. This is why you have a few options like reflog, reset, and checkout. Even better, as you break things, you will become more assured of how to fix things.

Real-Life Git Advice

Here’s some advice that helped me:

  • Start with a GUI, tools like GitKraken, Sourcetree, and the Git panel in VS Code really make it clearer when you're getting started. But then transition to the terminal slowly.

  • Learn the basic commands: clone, add, commit, push, pull. You should really get those down cold.

  • Branching is cheap, so take advantage of it and branch often to experiment.

  • Pay attention to the error messages. Git's error messages are long and sometimes verbose, but they usually indicate what went wrong.

  • Don't be afraid of rebase, but also don't use it blindly. Know how to rebase, and what you should be rebasing versus merging.

  • Use git status all the time. It's your best friend, I promise.

Why It's Worth It

If you're working with code, you're working with Git. Whether you’re solo or on a team of 100, version control is non-negotiable. And Git, for better or worse, is the industry standard.

Once you get comfortable with it, you’ll find yourself doing things like:

  • Fixing a bug from three months ago with one cherry-pick

  • Squashing messy commits before a pull request

  • Debugging a production issue by bisecting your commit history

  • Resolving merge conflicts without breaking a sweat

That’s the kind of power that Git gives you. It's not flashy, and it's not easy at first. But it’s absolutely worth learning.

Top comments (0)