我正在一台 OS/X 机器上工作,并且有一个运行在上面的 CentOS 7 虚拟机。我在我的驱动器上设置了一个单独的(区分大小写)分区,其中包含在两台计算机之间共享的文件夹,以便我可以在 OS/X 中工作,但在 CentOS 中构建。我有理由。
这几乎总是不是问题。然而,对于特定的 git 存储库,我似乎遇到了一些奇怪的事情:
如果我跑git status
在 OS/X 终端中,我得到一个干净的存储库:
$ git status
On branch 3.2.1
Your branch is up to date with 'origin/3.2.1'.
nothing to commit, working tree clean
但是,如果我在虚拟机中运行完全相同的命令,我会得到以下信息:
$ git status
On branch 3.2.1
Your branch is up to date with 'origin/3.2.1'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: some/file
no changes added to commit (use "git add" and/or "git commit -a")
这里究竟发生了什么?请注意,这些变更均为实质性变更;这里还有另一个关于行结尾的问题,这并不是它声称在这里找到的区别。
(对于某些上下文:我只是注意到这一点,因为我在虚拟机中进行了更改,提交了它们,并从虚拟机内将它们全部推送;但是,VS Code 声称我没有进行这些更改,这与我所看到的一致之后在远程上。然后从 OS/X 提交并推送这些更改后,现在虚拟机认为发生了一些有趣的事情。查看来自git diff
,它与文件的当前版本不匹配:即最后一次提交删除了几行,但 git diff 似乎认为我已将它们添加回来:
$ git diff
diff --git a/some/file b/some/file
index 8444607..d42b59a 100644
--- a/some/file
+++ b/some/file
@@ -167,6 +167,9 @@
... snip ...
+
+Lines that were deleted in the last commit
+Another line that was deleted in the last commit
A line that is in the current file
)
(一些附加信息,以防相关:这全部位于另一个模块的 git 子模块内)