本节带来 git 操作的小技巧
git checkout -b new_branch_name
git status
git branch
git add .
git commit -m "commit message"
git push origin branch_name
git merge branch_name
git reset --hard HEAD^
git reset --hard commit_id
git log
cd /your project dir
git shortlog -sn
git shortlog -sn --all
git shortlog -sn > ranking.txt
# 找到 --force 强制推送之前 commit 的 SHA 值
git reflog
注意 使用 git reset --hard 命令会将工作目录中未提交的更改删除,请谨慎使用。如果您有未提交的更改,请先使用 git stash 命令将其保存
git reset --hard <commit-SHA>
# branch/commit 要切换的分支名称
# path 文件目录,需要在项目之外 通常使用 ../git_worktree/branch[分支名称]
git worktree add <path> <branch/commit>
# 当分支不存在时,使用-b创建新的分支
git worktree -b add <path> <branch/commit>
# code是vscode终端命令 跟上文件目录 此时你相当于重clone了一个仓库
code ../git_worktree/branch
评论: