在 Git 中编辑根提交? [英] Edit the root commit in Git?

查看:29
本文介绍了在 Git 中编辑根提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有多种方法可以更改以后提交的消息:

There's ways to change the message from later commits:

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

如何更改第一次提交(没有父提交)的提交消息?

How can you change the commit message of the very first commit (which has no parent)?

推荐答案

假设您有一个干净的工作树,您可以执行以下操作.

Assuming that you have a clean working tree, you can do the following.

# 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

这篇关于在 Git 中编辑根提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆