Skip to content

Latest commit

 

History

History
36 lines (35 loc) · 748 Bytes

git-cheatsheet.md

File metadata and controls

36 lines (35 loc) · 748 Bytes

Git commands

  • Mingfei Sun
  • Created at: 2018-07-23
  • Modified at: 2018-07-25

Branch operations

  • Create a new branch from current branch
git checkout -b <new_name> 
  • Checkout to the new branch
git checkout <new_name>
  • Delete a branch
git branch -d <new_name>
  • Delete dead files in history
git gc --prune=now --aggressive
  • List large file
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
  • merge
# under current branch
git merge <new_branch>