Last active
December 18, 2017 15:46
-
-
Save rcanepa/deb63f4f91376439fb952a7de16f39a0 to your computer and use it in GitHub Desktop.
Git and bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- fetch a git commit log | |
git log -1 <hash> | |
- fetch commit list (reversed: last one is first) | |
git rev-list HEAD | |
- execute git log for every commit (on the reversed commit list) | |
git rev-list --reverse HEAD | while read rev; do git log -1 $rev; done | |
- print file tree for every commit | |
git rev-list --reverse HEAD | while read rev; do echo; echo REV $rev; git ls-tree $rev; done | |
- print every file hash (recursively) from all commits | |
git rev-list --reverse HEAD | while read rev; do echo; echo REV $rev; git ls-tree -r $rev | awk '{print $3}'; done | |
- print the file content from a file hash | |
git show <hash> | |
- to show a history of changes to a particular file | |
git log -p -- path/to/file | |
- show commits in which a file was affected | |
git log --name-status --follow --oneline <filename> | |
- diff filter on file over commits history (M = modified, A = added, R = renamed, ...) | |
git log --oneline --diff-filter=M src/clojure/scv2backend/models/acc_accounts.clj | |
git l --diff-filter=M src/clojure/scv2backend/models/acc_accounts.clj | |
- grep over commits history | |
git log --oneline --grep=<text> | |
git l --grep=<text> | |
More: | |
http://ohshitgit.com/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment