These are some miscellaneous git notes for features I don't use on a daily basis, but find useful every now and then.
-
git log --all -- '**/some-image.png'
search across branches for a specific file -
git diff --no-index <file1> <file2>
local diff of two files using git -
git log -S <text>
search for text across commit history -
git shortlog -s -n --all --no-merges -e
list all authors and number of commits -
git add -p
orgit add --patch
selectively stage specific chunks of changes -
Selectively patching from a diff, more granularly for taking specific changes than just cherry-picking if they're mixed up across different commits
1# Create a patch file from a diff
2git diff branch-1 branch-2 > temp.patch
3# edit temp.patch down to desired changes and save it
4# apply the patch
5git apply patch temp.patch
- Getting a true merge diff, sometimes more clarity is need then the default git diff algorithm or ones used by various remote repositories
1git merge <target-branch> --no-commit
2git diff --staged
3git merge --abort
last updated: