Git 删除提交\commit的log记录、修改历史提交消息、删除历史提交、修改所有提交的邮箱地址、从所有提交中删除一个文件 |
您所在的位置:网站首页 › 所有的邮箱 › Git 删除提交\commit的log记录、修改历史提交消息、删除历史提交、修改所有提交的邮箱地址、从所有提交中删除一个文件 |
Git使用小结
git教程推荐删除历史提交log记录(合并提交)情景如下操作步骤
修改历史提交消息删除历史提交修改所有提交的邮箱地址从所有提交中删除一个文件
git教程推荐
折腾git,被git折腾,还是保持够用就好的原则? https://backlog.com/git-tutorial/cn/stepup/stepup7_1.html https://git-scm.com/book/zh/v2 http://gitbook.liuhui998.com/index.html 以下情景都属于改写提交 基本都是基于git rebase命令 删除历史提交log记录(合并提交) 情景如下回到第一次提交commit 1请使用git rebase -i --root master 1 . git rebase -i到commit 2的上一次提交commit 1 git rebase -i 5a25878 # 执行完毕会弹出编辑器2 . 修改commit 3 pick命令为squash, 和commit2 合并(squash命令: use commit, but meld into previous commit/使用提交,但合并进先前的提交) # 编辑前内容 pick 8a98f84 commit 2, add 2.txt pick 5d2b9ba commit 3, add 3.txt pick 0768163 commit 4, add 4.txt pick 22e45ec commit 5, add 5.txt # Rebase 5a25878..22e45ec onto 5a25878 (4 command(s)) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # d, drop = remove commit # # 编辑后内容 pick 8a98f84 commit 2, add 2.txt # 修改了改行 squash 5d2b9ba commit 3, add 3.txt pick 0768163 commit 4, add 4.txt pick 22e45ec commit 5, add 5.txt3 . 保存上一步文本内容, 会弹出编辑器提示修改两次合并后的消息内容, 删除 commit 2的消息, commit 3不变, 然后保存 效果如下,仅删除了提交记录log,文件内容保持不变 修改最近一次提交信息 git commit --amend # 修改保存即可修改以前的提交信息 回到第一次提交commit 1请使用git rebase -i --root master # git rebase -i 要修改的commit的上一级commit id # 使用reword命令 # 22e45ec commit 5, add 5.txt # 0768163 commit 4, add 4.txt # 5d2b9ba commit 3, add 3.txt # 8a98f84 commit 2, add 2.txt # 5a25878 commit 1, add 1.txt # 以修改commit 2为例, 先rebase到commit 2的上一级commit 1 git rebase -i 5a25878 # 修改commit 2的rebase命令pick为reword # 保存,弹出编辑器提示修改提交信息,修改为要更正的信息保存即可回到第一次提交commit 1请使用git rebase -i --root master 无冲突 git rebase -i 要修改的commit的上一级commit id使用drop命令应用到commit 2有冲突 情景 需要删除commit 2提交,但commit 6依赖2.txt, 而 commit 2创建的2.txt |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |