小技巧
revert of the revert
- •设想一种场景,你开发了A分支,然后A分支merge进master,然后你发现这个merge有问题,于你进行revert,但是revert之后, 如果你再merge A分支进master的话,你会发现没有任何改变,也就是说A分支不会合并进来,因此你要对revert进行revert。
撤销某个merge
code
git revert <id> -m 1
.git/info/exclude
- •.gitignore可以忽略你不想提交的文件,但是.gitignore文件产生修改,并且可能会提交上去。因此如果你想针对本地忽略一些文件,可以在.git/info/exclude中写上
- •只适用未被 git 追踪的文件,如果要想忽略看下面第2点
git update-index 两种用法区别
- •--assume-unchanged is the flag which means the files should not change locally.
- •--skip-worktree is the flag which means the files should change locally. 一般情况下都用这个
- •How to ignore files already managed with Git locally
- •https://fallengamer.livejournal.com/93321.html
git stash apply --index
- •--index 可以回到stash时的状态,如果不加,那么都是unstaged状态
删除远程分支
- •git push origin --delete feature/login
git log匹配message
code
git log --grep=message
Restoring deleted files in Git
commit规范建议
code
feat: 新功能(feature) fix: 修补 bug docs: 文档(documentation) style: 格式(不影响代码运行的变动) refactor: 重构(即不是新增功能,也不是修改 bug 的代码变动) test: 增加测试 chore: 构建过程、辅助工具的变动 perf: 提高性能