Gitting Started (Part V): When Sh*t Goes South
If you’ve been following this series up till now, you’ve learnt quite a bit of the basic functionality of Git. However, you still haven’t encountered its most compelling use case: fixing things when they go wrong. Things can go wrong in a number of ways during software development — and things do love to go wrong. In this post, I’ll introduce some Git commands you can use to fix mistakes and, if need be, restore code to an earlier version:
git checkout
git restore
git rm
git log
git revert
git reset
In this post, I’m assuming you’ve learnt the things covered in the first four parts in the series, so if you see something you don’t know, chances are it’s covered in one of the previous posts.
Like in the rest of this series, this post assumes you are using a UNIX-based operating system, such as Mac OS X or some form of Linux, and that you have basic familiarity with using the command line on your system. Git is available for Windows as well, but since I don’t use Windows, I’m not able to speak to the ways usage may differ on a Windows system.