Отредактировать корневую фиксацию в Мерзавце?

Существуют способы изменить сообщение от более поздних фиксаций:

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

Как можно изменить сообщение о фиксации самой первой фиксации (который не имеет никакого родителя)?

305
задан Martin G 22 February 2015 в 21:27
поделиться

2 ответа

Предполагая, что у вас есть чистое рабочее дерево, вы можете сделать следующее.

# 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
262
ответ дан 23 November 2019 в 01:19
поделиться

Вы могли бы использовать GIT FILTER-FILINT :

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
4
ответ дан 23 November 2019 в 01:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: