Combining git navigation commands
Heres a quick git tip:
Everyone who uses git probably knows the commands
git checkout and
git reset. But for a long time, I did not really know what exactly they do.
The key is understanding that there are three different aspects of your git repo that can change: If you do a
git checkout <branch>, the branch will change, but the head and working tree will change along with it. On the other hand, if you do a
git reset <branch>, only the head will change. And then there is the option to do
git reset --hard <branch>, which is just like the regular reset, except that it also changes the working tree.
By combining these basic commands, you can achieve any state you want. Here is a full table: