Git History.
11.2.2016
Want to take a spin in the good old git time machine? Here are some useful way to do that.
git show --name-only [sha]
- Show which files have changed between the referenced [sha] and the current HEAD.
git log --grep=[stuff]
- Show any commits where the commit message matches the regular expression [stuff].
git log -p [filename]
- Show the log (commits and changes) for a the file [filename]. You can add any
log
arguments to this, such as 25 for only the most recent entries in the log:git log -p -25 README.md
. git grep [stuff]
- Use the power of git to search for any matches of the regular expression [stuff] in the repo.
Piping Output
- If the results are too difficult to read in your terminal, you can pipe the results to your test editor. For example, to pipe the output to Sublime from OSX's Terminal:
git log -p -2 README.md | subl
. - Or you can pipe those results to a file to save them. For example, to send the results to a file in Windows' Command Line:
git log -p -25 > file.txt
Permalink
Tags: