上下文:
我正在学习如何在Eclipse中使用git,并将其用于一个只有本地存储库的小型项目。
问题:
试图解决问题的艰难尝试:
我尝试过创建新的分支,修改提交,然后重新建立基础,但最后却出现了一堆看起来可怕的合并冲突和一棵看上去像意大利面的历史树。我可以将更新的提交复制并粘贴到txt文件中,用错误的信息恢复到提交,然后从那里重新开始,但我认为使用git的全部目的是避免做类似的事情。
问题:
是否有一种简单的方法只需更改旧提交的描述文本?
如果不是的话,复杂的方法的步骤是什么?!
发布于 2014-05-26 11:46:03
如果您已经将修改推到了某个地方:,不要!
否则:使用git rebase -i 并使用r(eword)选项标记要更改的提交。
一旦关闭弹出的文件,就会启动重基,并提示您输入新的提交消息。
假设您有以下提交历史记录(最新的第一次提交):
f6f6f6f last commit
d4d4d4d ...
c3c3c3c third commit
b2b2b2b second commit
a1a1a1a first commit如果要更改b2b2b2b和c3c3c3c的消息,请执行以下操作
git rebase -i a1a1a1a接下来,您最喜欢的编辑器将弹出并显示以下对话框:
pick f6f6f6f last commit
pick ...
pick c3c3c3c third commit
pick b2b2b2b second commit
# Rebase b2b2b2b..f6f6f6f onto a1a1a1a
#
# 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
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out将pick更改为r或reword以便提交b2b2b2b和c3c3c3c,保存文件并退出编辑器。
下一步,重新基地将开始。
对于选择为reword的提交,可以输入新的提交消息。
https://stackoverflow.com/questions/23869225
复制相似问题