A collection of git commands and also a method of recording my git knowledge
Add changes hunk by hunk (aka patch
)
git add -p
Edit previous commits
git rebase -i <commit ID>
Add all untracked files to the index without adding content (good for use with patch
)
git add . --intent-to-add
OR
git add -N .
Fetch and merge remote changes as a rebase instead of on top
git pull --rebase <remote name> <branch name>
Revert a single file to HEAD
git checkout <filepath>
Delete already merged branches from master
git remote prune origin
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
Show edits to a given file and search for a term, showing 10 lines before and after
git log -p path/to/file.py | grep -C 10 'your search term'