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

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

问题描述

有一些方法可以改变以后提交的消息:

  git commit --amend#对于最近的提交
git rebase --interactive master〜2#但需要* parent *

如何更改第一次提交(它没有父项)的提交信息? 解决方案

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

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

#修改提交
git commit --amend

#将master中的所有其他提交转换为修改后的根
git rebase --onto HEAD HEAD master


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天全站免登陆