created on 2022-01-31
Git Tips
When I first started programming more than a decade ago, I didn't know there were version control systems. I was simply copying, pasting code using temporary files. It was primitive even for a caveman. After finding out about version control systems a few years into my career, I've realized how fundemental they are in a programmer's toolbox. Nowadays, I use VCS, mainly git, for anything text, from my journal to the keto recipes.
Here are some of the git commands I use the most for future reference.
git switch: I found about this while writing this post and it made a lot of sense that I've decided
to include it. git switch <branch>
is same as git checkout <branch>
.
git restore: This one takes place of git checkout
git rebase:
git bisect: This is used to pinpoint a commit where a specific thing is introduced. It usually is a bug but you can search for anything since it is just a binary search. So next time you are looking for a bug in the previous commits remember this command instead of randomly picking commits or trying to do a binary search using your primitive brain. I did that many times.
git fetch --prune: I use this to clean the branch references deleted by others. I think most of the git clients do this automatically but since I only use terminal, I have to do it every once in a while.
git stash: I use stashing to remove my changes very quickly without losing them. I also different implementations of the same feature when performance test is necessary. Creating branches might be overkill.