【问题标题】:Git Working tree is dirtyGit 工作树很脏
【发布时间】:2013-11-12 10:31:42
【问题描述】:

如果我执行git review git 会显示“工作树脏”错误。

我做了一个提交并发送给审查。之后,我使用git pull 从上游更新分支。现在我需要修改之前的提交信息,所以,有我的命令:

1) git reset <id-of-the-commit-to-modify>

2)git commit --amend

vim 被打开来修改我的提交。但是这里也出现了关于我的提交和其他提交的信息,我不知道为什么。但是,我修改了提交消息并写入/关闭 vim。

3)git review

此命令引发此错误:

Errors running git rebase -i remotes/gerrit/master
doc/source/configuration.rst: needs update
doc/source/developing.rst: needs update
tools/sample_data.sh: needs update
Working tree is dirty

我做错了什么?

【问题讨论】:

  • git status 告诉你什么?

标签: gerrit git-commit git


【解决方案1】:

git reset <id-of-the-commit-to-modify> 没有模式选项默认为 --mixed 。这是manual中重置时所说的

--mixed
 Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.

这基本上意味着您的索引已被重置,但不是您的工作文件。因此,您从上游提取的所有文件仍保留在您的工作树中。 您应该使用git reset --hard <id-of-the-commit-to-modify> 这将重置您的索引并删除您的上游拉取附带的文件。然后,您可以修改您的提交并将其发送以供审核。

【讨论】:

    【解决方案2】:

    一旦将更改推送到 Gerrit,就可以直接获取它。在 Gerrit 审查板上,您可以找到每个补丁集的 chekcout 命令,如下所示:git fetch ssh://ebalbar@gerrit.ericsson.se:29418/TCC/TitanSim refs/changes/86/129686/5 && git checkout FETCH_HEAD 然后,您可以像往常一样修改提交,并再次推送新的更改。在签出您的本地分支并使用远程分支重置它之后:git reset --hard origin/<remote_branch> 还有一个很好的answer 如何修改直接推送的提交。

    【讨论】:

      猜你喜欢
      • 2012-04-09
      • 2023-03-18
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-27
      • 2015-08-26
      相关资源
      最近更新 更多