怎么修改git提交过的内容

2025-05-10 06:17:42
推荐回答(1个)
回答1:

先用git rebase 187f869c9d54c9297d6b0b1b4ff47d2ec781a55e^ --interactive //退回到要修改的commit的前一个点上,
执行后,git会调用默认的vi编辑器显示commit到最新commit的所有记录,把我们要修改的那一项的首行的pick 改成edit。

Step 2: 修改完我们要修改的内容后,利用git add 添加
git add

Step 3: git commit --amend //修改这个commit

Step 4: Git rebase --continue // 提交修改后的commit 并且返回到原来的head 处。

Fixing git: “interactive rebase already started”

If you’re like me, a fan of rebasing local work before publishing, maybe you receive this error:

"interactive rebase already started"

This happens when you abort in the middle of a rebase.

The way to fix it is using:

git rebase -i --abort