How to Learn Git From Scratch
If you want to work with code in any capacity then at some point you’re going to have to learn source code management (SCM). For any tech job using code you will be expected to be proficient with SCM and there is no source code management tool more ubiquitous than git.
Why Learn Git?
There are many reasons why SCM is so useful and to an extent the advantages of git are synonymous with the advantages of source code management as a whole. I have outlined four of the myriad reasons git is a must have skill below:
git is an industry standard. There are perhaps others SCM tools with more intuitive UIs or better workflows but none are as pervasive as git.
It gives you the ability to use remote repositories such as GitHub and GitLab for collaboration on a project.
Makes it easy to track changes to code and keep a thorough version history
When using a remote repository in conjunction with local repositories git gives you backups on backups on backups. (what is a git repository?)
When I first started this journey I had a vague idea of what GitHub was and I had heard of git itself, but had no clue of it’s inner workings. You may be the same! Everyone has to start somewhere so I’ve written this post to share a few resources I found useful along the way.
You will find git clunky and unintuitive when you first begin using it, but it will come to you and the basics are very simple to master especially compared to an entire programming language!
How to Learn Git
There is one resource that I found absolutely invaluable when I was trying to learn git. That resource is Net Ninja’s 12 video YouTube playlist on git and GitHub. In this series of videos he takes you right from the basics of installing git all the way to merging branches, using remote repositories and creating forks.
This series breaks git down into understandable easy to use chunks that you can learn bit by bit. Additionally throughout the whole process you are encouraged to follow along using git on your own machine. In this way you are not only learning in theory but also learning by doing, the best kind of learning!
I cannot overstate how much this helped me come to grips with git and would encourage anyone also trying to pick up git to make it their first priority.
Once you have been through the playlist you should have a pretty decent understanding of the workflow. The best part is because the playlist is broken into logical chunks you can easily return back to a video on a specific topic if you are stuck in future.
Additionally once you have watched the series you will have a much easier time navigating written tutorials when you are stuck and have to google a problem.
Next Steps
After you go through Net Ninja’s video series and have a good understanding of git, the best thing for you to do now is practice.
Whenever you start a coding project make sure you initialise a git repository. You can can commit all your project’s main changes on this repository and it will help further cement the basics of git.
If you are stuck on a particular bit of git create a practice repo and have a play around, this way if you mess up and don't know how to fix it there’s no problem, just delete the repo!
Once you start using it regularly git comes naturally. I find the most important thing is to know the common commands in git and then beyond that to understand what is possible and the general workflow. For instance when it comes to “git rebasing” I keep an Evernote on the command flow rather than trying to keep it all in my head.
One More Resource: LearnBranching
Once you have a good grip on the basics there is one more resource which you will find useful: Learn Branching
LearnBranching provides an interactive browser based git tutorial for you to visualise and learn more complex git commands. This is a very helpful tool but it is not a be all and end all. There is no repetition, it only goes through each concept once before moving on so you really want to have a good understanding of the basics before using it.
However be sure to give it a try when you’re ready to level up your git-fu.
Believe it or not, that’s it! Git is actually surprisingly quick to learn you just have to apply yourself to practicing and using it regularly. Good luck!