[英]change previous commit message after squash, not pushed
My scenario: I tried squashing 3 commits, the messages from 2 got combined with the last commit before branching, I want to remove the dummy commit messages. 我的场景:我尝试压缩3次提交,2次的消息与分支前的最后一次提交相结合,我想删除虚拟提交消息。
(Sorry the samples below aren't direct copies from the terminal, just my interpretations.) (对不起,下面的示例不是终端的直接副本,只是我的解释。)
I had 7 commits in a row. 我连续7次提交。 3 of them were ones I wanted to squash before merging my branch back into master. 其中3个是我想要将我的分支合并回主人之前要挤压的人。
af7d12c31e123023425a7b6f88bd3d6f43103358 dummy commit 3
69ec87cf490313086627df5224a1bcdbd3e9addd KEEP THIS COMMIT 4
fd6c843d59451c017628d03f3b4674045f06e54a KEEP THIS COMMIT 3
9ec44b48384373cbc8571b6beba7fd094db03e93 KEEP THIS COMMIT 2
53b8a217a4dcc85fb74e7c57861253f801ff882a KEEP THIS COMMIT 1
914dc32f7882b2b459e46b35a9314aef1c6824ba dummy commit 2
290f261f9d1541967f491fe8cba0fdd085ad5c20 dummy commit 1 (1st one in branch)
98dfb5299b122e496aeae29142038894488f0871 LAST COMMIT BEFORE BRANCHING
I ran 我跑了
git rebase --interactive 98dfb5299b122e496aeae29142038894488f0871
I then set the 3 dummy commits (1,2,3) to squash. 然后我将3个虚拟提交(1,2,3)设置为压扁。 Saved and rebase finished. 保存和rebase完成。
Now when I "git log", the commit message for 98dfb5299b122e496aeae29142038894488f0871 looks like: 现在,当我“git log”时,98dfb5299b122e496aeae29142038894488f0871的提交消息如下所示:
commit 98dfb5299b122e496aeae29142038894488f0871
Author: <me>
Date: Thu Apr 25 14:51:28 2013 -0700
LAST COMMIT BEFORE BRANCHING
dummy commit 1
dummy commit 2
I ran git rebase again from the same commit, 98dfb5299b122e496aeae29142038894488f0871, and changed that commit to "reword" and changed the message but it didn't have any effect. 我从同一个提交,98dfb5299b122e496aeae29142038894488f0871再次运行git rebase,并将该提交更改为“reword”并更改了消息,但它没有任何效果。
I have not pushed any of these changes yet, just committed locally on my branch. 我还没有推动任何这些更改,只是在我的分支上本地提交。
Do I need to rebase again but from the parent of LAST COMMIT BEFORE BRANCHING? 我是否需要再次进行转折,但要在分支之前从最后一次委托的父母那里进行转换?
To start, a few notes: 首先,请注意几点:
if 98dfb529
was the last commit before branching (that is, it appeared both in master and in your branch), then setting the first and second commits of your branch as "squash" ( 290f261f
and 914dc32f
) effectively moved the branching point one step before. 如果98dfb529
是分支前的最后一次提交(也就是说,它出现在master和分支中),那么将分支的第一次和第二次提交设置为“squash”( 290f261f
和914dc32f
)会有效地将分支点移动一步。 This is because 98dfb529
does not exist anymore in your branch, and it has been replaced by a squashed 98dfb529
+ 290f261f
+ 914dc32f
(let's call it aaaaaaaa
). 这是因为98dfb529
在您的分支中不再存在,并且已被替换为被压扁的98dfb529
+ 290f261f
+ 914dc32f
(我们称之为aaaaaaaa
)。 98dfb529
, however, still exists in master. 但是, 98dfb529
仍然存在于master中。
Then you decided to do the reword
on aaaaaaaa
. 然后你决定做reword
上aaaaaaaa
。 You changed the commit message. 您更改了提交消息。 This change triggered a change in the commit hash itself, so now your branch contains bbbbbbbb
instead of aaaaaaaa
. 此更改触发了提交哈希本身的更改,因此现在您的分支包含bbbbbbbb
而不是aaaaaaaa
。 aaaaaaaa
, however, still exists around, even if it is not directly referenced by any branch: it will be deleted the next time that git triggers a garbage collection of dangling commits. 然而, aaaaaaaa
仍然存在,即使它没有被任何分支直接引用:它将在下次git触发悬空提交的垃圾收集时被删除。 Therefore, a git log aaaaaaaa
will still show you the old message. 因此, git log aaaaaaaa
仍然会显示旧消息。
To recap, this is probably your current situation: 总结一下,这可能是你目前的情况:
(..your branch..)
|
* af7d12c3 // Note however that these five commits
* 69ec87cf // have now a different hash, because
* fd6c843d // the history has been changed: when
(..master..) * 9ec44b48 // the parent of a commit changes, then
| * 53b8a217 // the child's hash changes as well.
* 98dfb529 * aaaaaaaa * bbbbbbbb
| | |
| __________/____________/
|/
(... previous history ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.