使用git rebase编辑提交 [英] editing commits with git rebase

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

问题描述

我在编辑提交时遇到问题.

I'm having a problem with editing commits.

我对2个.php文件进行了2次提交.我的目标是同时编辑它们.我读到有关rebase -i的信息,这是我认为应该做的:

I have 2 commits for 2 .php files. My goal is to edit them both. I read about rebase -i and this is what I reckon is supposed to be done:

  • 首先我将pick更改为edit;
  • 保存并退出;
  • 变基停止;
  • 类型git commit --amend;
  • 进行更改,保存并关闭文本编辑器;
  • 键入git rebase --continue.
  • first I change pick to edit;
  • save and exit;
  • rebase stops;
  • type git commit --amend;
  • make changes, save and close the text editor;
  • type git rebase --continue.

在此之后,我相信重新设置会再次停止,因此我必须再次进行第二次提交.

After this I believe the rebase stops again and I have to do this all over again for the second commit.

但是在我键入git rebase --continue之后,我得到了:

But right after I type git rebase --continue i get this:

file1.php: needs update
You must edit all merge conflicts and then
mark them as resolved using git add

问题出在哪里,我该怎么办?

What is the problem and what do I do?

推荐答案

当您停止进行变基时,您必须:

When you stop for the rebase you have to:

  • 编辑文件
  • 将更改添加到索引-git add changedFile
  • 修改更改-git commit --amend
  • 继续重新定级-git rebase --continue
  • edit a file(s)
  • add changes to the index - git add changedFile
  • amend changes - git commit --amend
  • continue rebasing - git rebase --continue

根据您的描述,您可能忘记了对索引进行更改.在这种情况下,git commit --amend不执行任何操作(没有要更改的更改).另外,在编辑文件之前,您已经git commit --amend了,这也是错误的(您必须修改已经在文件上进行的更改).

From your description it is possible that you forgot to add changes to the index. In that case git commit --amend does nothing (there is no changes to amend). In addition you have git commit --amend before you edit the file which is also wrong (you have to amend changes you already did on the file).

尝试按照我给的顺序执行步骤.

Try to apply steps in the order I gave.

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

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