Git CMD
Init global config
git config --list
git config --global user.name "AaronYang"
git config --global user.email aaron19940628@gmail.com
git config --global pager.branch false
git config --global pull.ff only
git --no-pager diff
change user and email (locally)
git config user.name ""
git config user.email ""
list all remote repo
git remote -v
Get specific file from remote
git archive --remote=git@github.com:<$user>/<$repo>.git <$branch>:<$source_file_path> -o <$target_source_path>
Clone specific branch
git clone -b slurm-23.02 --single-branch --depth=1 https://github.com/SchedMD/slurm.git
Update submodule
git submodule add –depth 1 https://github.com/xxx/xxxx a/b/c
git submodule update --init --recursive
Save credential
login first and then execute this
git config --global credential.helper store
Delete 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
Update remote repo
git remote set-url origin http://xxxxx.git