Diff And History
Things involving working with and viewing the history.
Excluding Files In Diff
A useful incantation of git diff
which can be used to exclude files in the diff output.
This can be extended to glob patterns as well. For example, an incantation that can be used to ignore all generated mock files and gRPC files in a Go project:
Source: Stack Overflow
Showing Only Changed Files In Git Log
This technique shows only the changed files in a git log call without having to show the entire patch:
Showing Specific Revision Of A File
To display the contents of a file at a given revision in Git, run the following command:
For example, to view the version of "README.md” on the dev
branch:
There is an alternative form of this command that will show the changes applied to that file as part of the commit:
This can be used alongside the log command to work out what happened to a file that was deleted.
First, view the history of the file. You are interested in the ID before the commit that deleted the file: attempting to run git show
using the deletion commit ID it will result in nothing being shown.
Then, use git show
to view the version before it was deleted:
Last updated