Git
GIT CHEATSHEET: https://ndpsoftware.com/git-cheatsheet.html
GitHub Training Kit: https://training.github.com/
GitHub Cheat Sheet: https://github.com/tiimgreen/github-cheat-sheet
github-git-cheat-sheet.pdf: https://github.com/github/training-kit/blob/main/downloads/github-git-cheat-sheet.pdf
Git常用命令
# 查看本地所有分支
git branch
# 查看远程所有分支
git branch -r
# 查看所有分支
git branch -a
# 切换到本地dev分支
git checkout dev
# 建立一个新的本地分支dev
git checkout -b dev
#添加commit信息
git commit -m "Bug fix."
# 显示最新的提交,新的在上面
git log
# 删除远程分支
git push origin --delete [branch_name]
# 获取远程仓库的新分支以及删除远程仓库已删除的分支
git fetch -p origin
git checkout file
git reset hash
# 重命名本地分支
git branch -n old new
# 修改 master 为 main
git branch -m master main
# 修改最新一次提交的用户名和邮箱
git commit --amend --author="New Name <new.email@example.com>"
rebase
【Git】rebase 用法小结:https://www.jianshu.com/p/4a8f4af4e803
修改第 2 个 commit 信息
-
首先 git log 记录那一行的 hash
-
git rebase -i HEAD~2 将那一行的 pick 改为 reword 或 r,保存并关闭
-
修改 commit 信息,保存并关闭
-
git push origin dev -f 强制提交
-
强制推送后别的仓库更新 git fetch origin && git reset –hard origin/dev