(A cheesy homepage for Justin Collins)
git revert a single file
git checkout <filename>

I’m putting that first for people who don’t need a story.

To be honest, I cannot believe it took me so long to find this out. It seems like such a simple thing. You have a git repo. You’ve made changes to a few different files, when you realize you just want to start over on one of them. You could do git reset --hard, but then you lose all of your changes. You could commit all the other changed files, then do a git reset, but what if you aren’t done with editing the other files?

In Subversion you can svn revert a single file. Since that is what I fairly frequently wish to do, I searched high and low for a way to do this seemingly simple operation.

Then, one day glorious day, I found it. And now so have you.


blog comments powered by Disqus