如何在Mercurial中編輯錯誤的提交消息? [重複]

本文翻譯自:How to edit incorrect commit message in Mercurial? [duplicate]

This question already has answers here : 這個問題已經在這裏有了答案
Closed 2 years ago . 2年前關閉。

I am currently using TortoiseHg (Mercurial) and accidentally committed an incorrect commit message. 我當前正在使用TortoiseHg(Mercurial),並意外提交了錯誤的提交消息。 How do I go about editing this commit message in the repository? 如何在存儲庫中編輯此提交消息?


#1樓

參考:https://stackoom.com/question/2c5E/如何在Mercurial中編輯錯誤的提交消息-重複


#2樓

Good news: hg 2.2 just added git like --amend option. 好消息:hg 2.2 剛剛添加了 git之類的--amend選項。

and in tortoiseHg, you can use "Amend current revision" by select black arrow on the right of commit button 在tortoiseHg中,您可以通過選擇“提交”按鈕右側的黑色箭頭來使用“修改當前修訂版”

一種


#3樓

Well, I used to do this way: 好吧,我曾經這樣做:

Imagine, you have 500 commits, and your erroneous commit message is in r.498. 想象一下,您有500次提交,而錯誤的提交消息在r.498中。

hg qimport -r 498:tip
hg qpop -a
joe .hg/patches/498.diff
(change the comment, after the mercurial header)
hg qpush -a
hg qdelete -r qbase:qtip

#4樓

In TortoiseHg, right-click on the revision you want to modify. 在TortoiseHg中,右鍵單擊要修改的修訂。 Choose Modify History->Import MQ. 選擇“修改歷史記錄”->“導入MQ”。 That will convert all the revisions up to and including the selected revision from Mercurial changesets into Mercurial Queue patches. 這樣會將所有修訂版本(包括從Mercurial變更集選擇的修訂版本)轉換爲Mercurial Queue補丁。 Select the Patch you want to modify the message for, and it should automatically change the screen to the MQ editor. 選擇您要修改消息的補丁,它將自動將屏幕切換到MQ編輯器。 Edit the message which is in the middle of the screen, then click QRefresh. 編輯屏幕中間的消息,然後單擊QRefresh。 Finally, right click on the patch and choose Modify History->Finish Patch, which will convert it from a patch back into a change set. 最後,右鍵單擊補丁,然後選擇“修改歷史記錄”->“完成補丁”,這會將其從補丁轉換回變更集。

Oh, this assumes that MQ is an active extension for TortoiseHG on this repository. 哦,這假設MQ是該存儲庫上TortoiseHG的有效擴展。 If not, you should be able to click File->Settings, click Extensions, and click the mq checkbox. 如果不是,您應該能夠單擊文件->設置,單擊擴展名,然後單擊mq複選框。 It should warn you that you have to close TortoiseHg before the extension is active, so close and reopen. 它應該警告您必須在擴展激活前關閉TortoiseHg,因此請關閉並重新打開。


#5樓

Rollback-and-reapply is realy simple solution, but it can help only with the last commit. 回滾和重新應用是非常簡單的解決方案,但是它只能在最後一次提交時提供幫助。 Mercurial Queues is much more powerful thing (note that you need to enable Mercurial Queues Extension in order to use "hg q*" commands). Mercurial Queues功能更強大(請注意,您需要啓用Mercurial Queues Extension才能使用“ hg q *”命令)。


#6樓

One hack i use if the revision i want to edit is not so old: 如果要編輯的修訂版本不太舊,我可以使用一種技巧:

Let's say you're at rev 500 and you want to edit 497. 假設您的轉速爲500,而您想要編輯497。

hg export -o rev497 497
hg export -o rev498 498
hg export -o rev499 499
hg export -o rev500 500

Edit rev497 file and change the message. 編輯rev497文件並更改消息。 (It's after first lines preceded by "#") (在第一行之後加上“#”)

hg import rev497
hg import rev498
hg import rev499
hg import rev500
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章