我刚刚完成了一个项目,想对其历史进行一些更改,使其看起来更整洁。我已经推送了这个项目,但还没有人分叉或工作,所以没有人会受到重写历史的影响。
我偶然发现了一些问题。7aba66b
在变基期间,我收到一条无法应用提交的消息。
免责声明:我知道一个 SO 主题不能包含多个问题,但我真的认为在这里将我的问题放在一个 SO 主题中是有意义的,因为它们密切相关,以至于将所有背景信息发布多次将是不必要的 SO 泛滥。更重要的是,我认为所有这些都有一个共同的根本原因,一个单一的答案将解决所有列出的问题。如果我错了,我会将这个问题分成几个问题。
首先,这是我的提交历史(忽略可怕的提交消息):
* 8870309 (HEAD, origin/master, master) Completed
* 7d70396 Completed
* aa3bd79 Completed
* 96c21f6 Completed
* ba9b4dd Completed
* eafcb19 Completed
* e0a7e91 Completed
* 455688a Completed
* 9e925bf Completed
* 7c800cf Completed
* 3d3c2e8 Completed
* 2420e22 Completed
* c7a8fa5 Completed
* a750f9b Completed
* 32eef0b Completed
* f6f5852 Completed
* 3998fcd Completed
* 5bf074d path progress
|\
| * 7aba66b Completed
* | 6b3d03d Completed
|/
* ed3ef53 Completed
* d9c97ec Completed
* 8684c7f Completed
* f05904a Completed
* a1fdf7c Completed
* c321a19 Merge branch 'master' of github.com:AlexVPopov/rubykoans
|\
| * aca7987 Initial commit
* 9359dd1 Initial commit
所以,我觉得奇怪的第一件事是 - 为什么aca7987
和7aba66b
显示在不同的分支上,因为它们都在 master 上?如果我跑,git branch --contains aca7987
我会得到master
. 我怀疑这可能是因为我在分支 X 上进行了更改,而不是先签出 master 而没有提交这些更改,然后将分支 X 合并到 master 分支,删除分支 X 然后提交更改。
我想将所有提交的提交消息更改为“已完成”。所以我跑git rebase -i 9359dd1
。我明白了:
pick aca7987 Initial commit
pick a1fdf7c Completed
pick f05904a Completed
pick 8684c7f Completed
pick d9c97ec Completed
pick ed3ef53 Completed
pick 6b3d03d Completed
pick 7aba66b Completed
pick 3998fcd Completed
pick f6f5852 Completed
pick 32eef0b Completed
pick a750f9b Completed
pick c7a8fa5 Completed
pick 2420e22 Completed
pick 3d3c2e8 Completed
pick 7c800cf Completed
pick 9e925bf Completed
pick 455688a Completed
pick e0a7e91 Completed
pick eafcb19 Completed
pick ba9b4dd Completed
pick 96c21f6 Completed
pick aa3bd79 Completed
pick 7d70396 Completed
pick 8870309 Completed
我更改pick aca7987
为r aca7987
,关闭编辑器,弹出新的编辑器窗口,更改Initial commit
为Completed
并关闭编辑器。然后我得到:
[detached HEAD da22506] Commit
Author: AlexVPopov <xxxx@xxx.xxx>
1 file changed, 4 insertions(+)
create mode 100644 README.md
error: could not apply 7aba66b... Completed
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
为什么会这样?谢谢你。