nyan~

Engineering Rocks!

Git Tips

1
repo forall -c "pwd && git status" 2>&1 | tee status.txt    # check status for each project
  • Find commit list which contains [function]
1
git show `git log --oneline [path-to-file] | cut -c 1-8` | egrep -rs "[function]|commit"
  • Search
1
2
3
git log --oneline --author=[email]
git branch --contains [commit id]
git log -S"keyword" [path-to-file]
  • Change Author
1
git commit --amend --author=[email]
  • Rebase
1
2
3
4
git rebase -i HEAD~[number_of_commits]
edit
git commit --amend
git rebase --continue
  • Reset
1
2
3
4
git reset --hard [commit-id]
git reset --soft @{1}
git reset --hard HEAD
git reset --hard HEAD^
  • Remote
1
2
git branch -r
git remote show origin
  • Diff
1
2
git log --oneline [tag1]..[tag2]
git log --oneline [branch1]..[branch2]
  • Patch
1
2
3
git format-patch <commit id>^!  # generate patch w.r.t. commit id
git format-patch -1             # generate patch w.r.t. top commit
git cherry-pick <commit id>     # cherry pick commit