git show
I was doing some debugging today and at one point was trying to find which file in a particular commit had caused a problem. First, of course, I checked out the commit right before this one to double check that the problem code was actually in that commit:
git checkout <COMMIT>~1
However, then I wanted to merge the changes from that commit into the repository one by one so I could narrow the problem down to a single file. I didn’t want to type everything out again by hand, so I used the following command to execute file changes one-by-one:
git show <COMMIT>:path/to/file/from/repo/root > path/to/file
It’s just a simple combination of the ‘git show’ command to see the file in a current commit and a Bash ‘>’ to pipe that content into the actual file and overwrite its content on disk.
Written by
Mpdaugherty on Friday, 10th June 2011.
Leave a comment.
Posted in:
Git