git stash -a ?//緩存所有文件
git checkout -b dev origin/dev //切換到dev分支上,接著跟遠程的origin地址上的dev分支關聯起來
//推送本地分支到遠程倉庫
git push origin localbranchname:remotebrancname
git revert onefile //https://www.freecodecamp.org/news/git-revert-file-reverting-a-file-to-a-previous-commit/
//Git中獲取當前分支名git
git branch --show-current
//git從指定的commit創建分支
git checkout -b branchname?<commit-hash>
//以下兩個命令需要在git bash下執行,因為window下找不到grep\xargs命令
//This script will delete all local branches except the master branch, including the non-merged branches.
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -D
//The -d is a soft delete option and only removes the merged branches.
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -d
//合并某個提交
git cherry-pick <commit-hash>
//列出包含某個提交的所有標簽
git tag --contains f3a0b78
//克隆某個Tag的代碼
git clone -b v9.2.2 https://gitlab.kitware.com/vtk/vtk.git
//回滾到某個提交
git log --oneline
git reset --hard <commit-hash>
git checkout -b branchname
git push origin localbranchname:remotebranchname