文章出處

今天發現一個項目的git commit message中的單詞拼錯了,需要修改一下。但這樣簡單的修改,需要通過git rebase才能完成。

首先要git rebase到需要修改message的那個commit的前1個commit。假設commit id是32e0a87f,運行下面的git rebase命令:

git rebase -i 32e0a87f

在git bash中運行上面的命令后,會彈出編輯框,在編輯框中會分行依次顯示以pick開頭的這個commit之后的所有commit message。

將需要修改的commit message之前的"pick"改為"reword",點擊保存按鈕,并關閉編輯框,這時會執行rebase操作。

Rebasing (1/3)

接著會再次彈出編輯框,這次編輯框中只有之前改為"reword"的那個commit message,此時修改commit message的內容,點擊保存按鈕并關閉編輯框,會繼續執行rebase操作。

如果操作成功,會出現如下的提示:

[detached HEAD aa3b52c] Add return url
 2 files changed, 1 insertion(+), 3 deletions(-)
Successfully rebased and updated refs/heads/oss.

這樣就完成了git commit message的修改,然后強制push一下就搞定了。

git push --force

【參考資料】

Changing a commit message


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()