簡體   English   中英

更改未刪除的上一個git commit消息

[英]Change unpushed previous git commit message

如何更改以前未刷新的git提交消息?

更新: 問題急劇減少,以適應答案。 要查看完整內容。 看歷史。

這樣做的正確方法是什么? 謝謝。

要更改最新提交的消息,請運行:

git commit -m "corrected message" --amend

就足夠了。

但是,如果您需要在最近之前更改提交消息,則應使用交互式rebase。 此示例允許您在最近之前更改提交的消息。 適當調整~2以進一步返回。

git rebase -i HEAD~2
<editor will open>
<change "pick" to "reword" for whichever commit(s) you wish to alter the message of>
<close/save the editor>
<for each commit you changed "pick" to "reword", git will present an editor with the existing commit message>
<update the commit message as desired and close/save the editor>

而已。 在每次提交后git停止后你從“pick”切換到“reword”,你將回到你的HEAD提交,並更新評論。 請注意,從第一次提交其注釋的提交開始,該提交和所有后續提交都將具有新的哈希。 由於您表示未提交提交,因此對於使用repo的其他人來說,這不應該導致問題。

你現在必須選擇提交:

git cherry-pick d91bd18

就是這樣!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM