在本地VM上登录时,为什么在共享文件夹中获得不同的git状态? [英] Why do I get a different git status in a shared folder when logged in on a local VM?

查看:90
本文介绍了在本地VM上登录时,为什么在共享文件夹中获得不同的git状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OS/X机器上工作,并且有一个在其上运行的CentOS 7 VM.我已经在驱动器上设置了一个单独的(区分大小写)分区,并在两台计算机之间共享了一个文件夹,以便我可以在OS/X中工作,但可以在CentOS中构建.我有原因.

I am working on an OS/X machine, and I have a CentOS 7 VM that I run on there. I have set up a separate (case-sensitive) partition on my drive with a folder that is shared between the two machines so that I can work within OS/X, but build in CentOS. I have Reasons.

这几乎始终不是问题.但是,对于特定的git存储库,我似乎遇到了一些奇怪的事情:

This is almost always not an issue. However, it seems that I have run into something strange with respect to a specific git repository:

如果我在OS/X终端中运行 git status ,则会得到一个干净的存储库:

If I run git status in the OS/X terminal, I get a clean repository:

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

nothing to commit, working tree clean

但是,如果我在VM中运行完全相同的命令,则会得到以下信息:

However, if I run the exact same command in the VM, I get the following:

$ 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")

这里到底发生了什么?请注意,这些更改是实质性更改;这里还有关于行尾的另一个问题,这并不是它声称在这里找到的区别.

What exactly is happening here? Note that the changes are substantive changes; there is another question on here about line endings, and that is not the difference it claims to find here.

(在某些情况下:我只是注意到了这一点,因为我在VM中进行了更改,将其提交并从VM中推送了所有这些内容;但是,VS Code声称我没有进行这些更改,这与之后我在远程上看到的内容.然后从OS/X提交并推送了这些更改,现在VM认为有意思的事情了.查看 git diff 的输出,它与文件的当前版本:即最后一次提交删除了几行,但是git diff似乎认为我已经将它们重新添加了:

(For some context: I only noticed this because I made changes in the VM, committed them, and pushed them all from within the VM; However, VS Code claimed that I had not made those changes, and that was consistent with what I saw on the remote afterwards. Having then committed and pushed those changes from OS/X, now the VM thinks that something funny is up. Looking at the output from git diff, it does not match the current version of the file: i.e. the last commit deleted a few lines, but git diff seems to think I have added them back:

$ 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子模块中)

(Some additional information, in case this is relevant: this is all within a git submodule of another module)

推荐答案

对于有价值的东西,以防万一有人遇到这个问题:看来这是两个操作系统上某种文件缓冲的问题.当我在OS/X中添加新数据并保存时,CentOS和OS/X都同意文件内容.我不确定为什么它们会不同步,但是进行了明确的更改并保存起来似乎已解决了该问题.

For what it's worth, in case someone else runs into this: It appears that this was some issue with some kind of file buffering on the two OSs. When I added new data in OS/X and saved it, both CentOS and OS/X agreed on the file contents. I'm not sure why they became out of sync, but making an explicit change and saving it seems to have fixed it.

这篇关于在本地VM上登录时,为什么在共享文件夹中获得不同的git状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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