首页 > 解决方案 > 即使在提交/推送之后也无法摆脱“要提交的更改”消息

问题描述

即使在提交并推送到原点后,我也会不断收到Changes to be committed来自命令的消息。git status我可以看到 origin/master 的变化。我怎样才能摆脱这个消息?

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:  foo.php

$ git commit -m 'message' foo.php
On branch master
Your branch is up to date with 'origin/master'.

nothing added to commit

编辑

实际上,foo.php 之前是一个不同的名称,比如 foo-org.php,我将其重命名为:

git mv foo-org.php foo.php

我运行 git add foo.php 然后 git commit -m 'renamed' foo.php 然后 git push orign master。我可以看到在线 repo (origin/master) 上的文件是最新的,所以我不知道为什么它仍然说“要提交的更改”。

标签: git

解决方案


由于远程主分支是最新的,请尝试将本地分支重置为它:

git fetch
git switch -C master origin/master

或者,如果您已经在本地master

git reset --hard origin/master

然后检查是否git status仍然报告非空索引。


推荐阅读