Git GUI to the Rescue
Lately, I've been really loving using sass to manage my css. It really takes a lot of the pain out of css. But, I just ran into an interesting problem. Just a few moments ago, I made the mistake of editing and commiting a css file instead of the corresponding scss file. The next time I changed the scss file, it overwrote changes in my css file. But, luckily, Git to the rescue!
I used the following to list all the commits where the file had changed
gitk (filename)
The gitk window shows a list of all the commits where my css file had changed. By clicking thu the commits at the top and looking for the lines of code that I lost in the "Diff" panel, I figured out that the changes were wiped out one commit ago (commit 2eaf5f594).
Next, I used this command to view the contents of the file as it existed in the commit before last:
git show HEAD^:(path-to-file)
Sure enough, I found my lost changes in the older version of the file.
To fix my mistake, I simply copied the changes back into the current version of the file. I could have also just as easily used the `git checkout` command to get the old version at HEAD.
Ahhh, Saved by the Git!
Also checkout the git gui
command for quickly creating commits.