← Back

~3 min read

Fastest way to git good (for beginners)

(Sorry but no, you don't need to be an hardcore gamer to be good with git!)

In a few words: always check what you're doing & what you're dealing with.

Know your environment

From my - short - experience, most people tend to run commands like commit, pull, push without being sure of where they are working (the damn branch they are on), not refreshing their index and sometimes they even don't just look to their current - git - history/tree! It always annoy me when someone decide to make a merge's commit for features that could have been fast-forwarded overwise.

I like to compare the way to do your git with the way you play an RTS (like SC2): you should always be aware of what's going on otherwise you expose yourself - and your team - to some troubles.

Habits to take for improvement

Following some rules that I'm gonna list below will result in:

  • 📉 less mistakes overall
  • 📈 a better understanding of git in the really short term

Those 2 changes will lead to more experimentation because of your confidence, thus more knowledges and productivity.

Here are my basic recos:

Be aware of the branch you're working on, as same as the directory you're in!

  • The first thing you wanna avoid is not working where you were supposed to.
  • In your terminal, you can show (with plugins or configurations) the branch you're on without executing any command: I personnaly use oh-my-zsh which directly print this information.

    ⚠️ You can abuse of the usage of git branch if you have no way to configure the shell you're using.

Do git fetch regularly and frequently.

  • There is no problem at all in doing it a lot!

    Actually there is one case when this tip does not apply: if you have a very bad connection or if the service (bitbucket, github) is either very slow or down.

  • Doing so you will be sure to see if any change is made and you won't have to do some extra tricks that you may not know yet.
  • ⚠️ The minimum is to do it before every commit, checkout, pull, push etc...

    Of course that also depends of the size of your team so don't take it literally! Try to force yourself to be used to do it first, then adapt the frequency to your needs.

Always fetch with the prune option (git fetch -p or git fetch --prune).

  • Because it shows you if a/some branch(es) has been removed.
  • Free information right here!

Use git status a lot.

  • It takes no time and it will give you some informations about your work.

    Heck, I even use it to remind myself what I'm doing when I need to do "multitasking"!

While trying new things, always take advantages of git status, git diff and git log

  • Did I just said "while trying new things"? Well I should have said "while doing anything" instead because it's a must do!

    ⚠️ Again, don't take it literally unless you're a beginner

  • That way you'll understand what practices are good/bad etc

    For example, you'll understand why rebase can be whether awesome or awful, depending on how you used it.

Last but not least, use the terminal and rtfm!

  • Stay in charge of everything by working with the term.

    You'll need a git log starter pack ;)

  • It's a thing to know when to ask for help, it's another thing to learn reading docs and manuals!

More to come...

Those were the basics - mine, at least. There are plenty of good commands/options that will help you to "git gud" and even better ; but after reading this and with a little practice, you should be able to find all what you need later on by yourself.

← Back