What good is a version control system if when you make that critical mistake you can't find the 'undo' button? Not much.

So if I want to see a list of past commits with comment, date, and files changed and revert to a specific version of a file:

git log --pretty=medium --abbrev-commit --name-status
commit 66408e0
Author: AJ ONeal
Date: Fri Nov 13 01:22:16 2009 -0700

BST memory leak fixed

M Makefile
M src/WebCrawler.cpp
M tpl/BST.h
M tpl/VectorSet.h

git checkout 66408e0 tpl/VectorSet.h

This came about because I was working on a homework project and I had made my VectorSet unnecessarily complicated and introduced some bugs. I wanted to revert to a previous (and simpler) version of the file... but I hadn't learned how to do such a thing yet.

After poking about in the man page I realized that the intuitive 'git revert' wasn't what I wanted and I thought 'git rev-list' was... but I was wrong. Thankfully, the fellows at my local LUG pointed me in the right direction.






By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )