vgrabovets
5/29/2018 - 7:26 AM

git commands

git commands

git log master..branch  # difference of commits between branches
git checkout branch_to_copy_from file_from_branch_copy_from  # copy file from another branch
git remote show origin
git remote prune origin  # remove stale branches
git config --global core.excludesfile ~/.gitignore_global  # global .gitignore

# remove big objects from repo
gic gc
git count-objects -v  # repo size
git verify-pack -v .git/objects/pack/pack-29...69.idx | sort -k 3 -n | tail -3  #  top 3 largest objects
git rev-list --objects --all | grep 82c99a3  # find object by SHA
git log -- file_name  # commits that modified file
git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_name' -- SHA^..  # delete, rewrite history
rm -Rf .git/refs/original
rm -Rf .git/logs/
git gc
git prune --expire now