376

後のコミットからメッセージを変更する方法があります。

git commit --amend                    # for the most recent commit
git rebase --interactive master~2     # but requires *parent*

最初のコミット(親がない)のコミットメッセージをどのように変更できますか?

4

5 に答える 5

643

Git バージョン1.7.12の時点で、使用できるようになりました

git rebase -i --root

ドキュメンテーション

于 2013-01-31T16:24:00.480 に答える
314

クリーンな作業ツリーがあると仮定すると、次のことができます。

# checkout the root commit
git checkout <sha1-of-root>

# amend the commit
git commit --amend

# rebase all the other commits in master onto the amended root
git rebase --onto HEAD HEAD master
于 2010-01-22T18:53:12.260 に答える
4

使用できますgit filter-branch

cd test
git init

touch initial
git add -A
git commit -m "Initial commit"

touch a
git add -A
git commit -m "a"

touch b
git add -A
git commit -m "b"

git log

-->
8e6b49e... b
945e92a... a
72fc158... Initial commit

git filter-branch --msg-filter \
"sed \"s|^Initial commit|New initial commit|g\"" -- --all

git log
-->
c5988ea... b
e0331fd... a
51995f1... New initial commit
于 2010-01-22T18:46:43.290 に答える