Cheatsheet
List config
git config --listInit global config
git config --global user.name "AaronYang"
git config --global user.email aaron19940628@gmail.com
git config --global user.email byang628@alumni.usc.edu
git config --global pager.branch false
git config --global pull.ff only
git --no-pager diffchange user and email (locally)
# git config user.name ""
# git config user.email ""
git config user.name "AaronYang"
git config user.email byang628@alumni.usc.edulist all remote repo
git remote -vClone specific branch
git clone -b slurm-23.02 --single-branch --depth=1 https://github.com/SchedMD/slurm.gitGet specific file from remote
git archive --remote=git@github.com:<$user>/<$repo>.git <$branch>:<$source_file_path> -o <$target_source_path>Update submodule
git submodule add –depth 1 https://github.com/xxx/xxxx a/b/c
git submodule update --init --recursiveSave credential
login first and then execute this
git config --global credential.helper storeDelete Branch
- Deleting a remote branch
git push origin --delete <branch> # Git version 1.7.0 or newer git push origin -d <branch> # Shorter version (Git 1.7.0 or newer) git push origin :<branch> # Git versions older than 1.7.0
- Deleting a local branch
git branch --delete <branch> git branch -d <branch> # Shorter version git branch -D <branch> # Force-delete un-merged branches
Prune remote branches
git remote prune origin