git rebase -i HEAD~3 # (number of commits)# ouput:# pick a# pick b -> change to squash a# pick c -> change to squash b# input commit message
inspect git tree
git log --oneline --decorate --graph -n 10git log --oneline --graph --all# alias for convienentgit config --global alias.lg "log --oneline --graph --decorate --all"# use: git lg
clean up local when fetch
git fetch --prune
rename a file
git mv old_name new_name
rename a branch
git branch -m new_name
rename a remote URL
git remote set-url origin https://github.com
file handling
# make git forget a file but keep on this# can apply for accidentall added untracked filegit rm --cached file# unstage a filegit restore --staged file # orgit reset HEAD file# delete file from git and diskgit rm file