Why do I get a different git status in a shared folder when logged in on a local VM?

Viewed 125

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.

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

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

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.

(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

)

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

1 Answers

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.

Related