Git 提交规范
| prefix | description |
|---|---|
| feat | A new feature |
| fix | A bug fix |
| docs | Documentation only changes |
| style | Changes that do not affect the meaning of the code |
| refactor | A code change that neither fixes a bug nor adds a feature |
| perf | A code change that improves performance |
| test | Adding missing tests or correcting existing tests |
| build | Changes that affect the build system or external dependencies |
| ci | Changes to our CI configuration files and scripts |
| chore | Other changes that don’t modify src or test files |
| revert | Reverts a previous commit |
Git 常用操作记录
创建远端分支
git push --set-upstream origin <branch-name>
删除远端分支
git push origin :<branch-name>
# 或者
git push origin --delete <branch-name>
从远程分支中创建并切换到本地分支
git checkout -b <branch-name> origin/<branch-name>
删除分支
git branch -D <branch-name>
重命名本地分支
git branch -m <new-branch-name>
交互式变基到指定记录
压缩commit记录
git rebase -i <commit-hash>
继续变基操作
git rebase --continue
修改 commit 注释信息
git commit --amend
撤销 commit 保留变动
git reset HEAD^ --minxed (默认参数)
撤销 commit 保留变动和 git add
git reset HEAD^ --soft
撤销 commit 并删除变动
git reset HEAD^ --hard
当前修改存储或取出到 stash
[see more]
git stash push/pop
清空所有的 commit
git update-ref -d HEAD
快速切换到上一个分支
git checkout -
关联远程分支
git branch -u origin/<branch-name>
展示本地分支关联远程仓库的情况
git branch -vv
从远程分支中创建并切换到本地分支
git checkout -b <branch-name> origin/<branch-name>
展示简化的 commit 历史
git log --graph --pretty=oneline --abbrev-commit