squash - rewrite history

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 10
git log --oneline --graph --all
# alias for convienent
git 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 file
git rm --cached file
# unstage a file
git restore --staged file
 # or
git reset HEAD file
# delete file from git and disk
git rm file

Git Internals - Refs, Branches, HEAD and Gerrit Refs

gitlab - github

gerrit work flow

Git Submodules

git troubleshoot

Recover Orphan Detached Commits

Git Cheat Sheet - Cleaning Up Orphan Commits