git进阶笔记
git 进阶笔记
漂亮的 log
git log --all --graph --decorate
blame
- 可以看到每一行代码的修改情况
commit
- 修改 commit 信息
git commit --amend
- 一次规范的 commit msg 应当包含简要描述、具体描述、提交人信息三方面的信息
stash
- 暂存未完成的工作
git stash push
git stash list
git stash pop
rebase
合并多次提交
当你在本地多次提交后想要向远程仓库master分支提交一次merge request,审批人嫌你的commit记录太乱了,要求合并为一个
git rebase -i <版本号>
跳入编辑页面,接着把自己不想要的commit的“pick”字段改为”s”(squash)
再跳入编辑页面,把自己不想要的commit信息注释掉
消灭之前的commit,注意和合并的区别
# E---F---G---H---I---J topicA
git rebase --onto topicA~5 topicA~3 topicA
# E---H'---I'---J' topicA
.gitignore
- 使 git 提交时忽略其中的文件
git + VScode
- 提交:见 VScode 侧边栏,add/commit/push等全部实现图形化界面
- blame :安装 gitLens 插件即可
git + zsh
- 使用 git 插件即可看到并使用众多的 alias e.g. glgga=’git log —graph —decorate —all’
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!