grizzlybears
grizzlybears

Reputation: 510

Many 'modified' files, just after 'git clone' or 'git checkout .'

I have a remote git repo, and I cloned from it as always. Then I 'git st' to have a check, but I got a list of 'Modified files', like:

user@DESKTOP-2RDUUGD srv_dev (shao) $ git st
Refresh index: 100% (13535/13535), done.
 M nms/bns/bin/malt_bns
 M nms/bns/src/bns_hndjdg/makefile.Linux
 M nms/bns/src/bns_jdg/makefile.Linux
 M nms/bns/src/bns_stoptrailmng/makefile.Linux
 M nms/bns/src/bns_tmsc/makefile.Linux
 M nms/bns/src/bns_tt_autocoop/makefile.Linux
 M nms/bns/src/com/makefile.Linux
 M nms/com/bin/icnv.sh
 M nms/com/bin/mk.mk
 M nms/com/bin/wu.mk
 M nms/com/bin/wu2.mk
 M nms/com/src/com/makefile.Linux
 M nms/com/src/sindan/makefile.Linux
 M nms/com/src/tool/menu/makefile.Linux
...

I picked some of those files, and the 'diff' is real(not just line end stuff) , like:

user@DESKTOP-2RDUUGD srv_dev (shao) $ git diff nms/tmsif/src/tool/trcsts/makefile.Linux
diff --git a/nms/tmsif/src/tool/trcsts/makefile.Linux b/nms/tmsif/src/tool/trcsts/makefile.Linux
index 3c31585a..b220657f 100644
--- a/nms/tmsif/src/tool/trcsts/makefile.Linux
+++ b/nms/tmsif/src/tool/trcsts/makefile.Linux
@@ -1,7 +1,7 @@
 #
 #        情報連携統合ビュー  MAKE
 #
-#              オブジェクト作成
+#              ロードモジュール作成
 #

 SRCPATH        = .
@@ -14,22 +14,27 @@ INCPATH5= $(OD_HOME)/include
 INCPATH6= $(TD_HOME)/include

 OBJPATH        = $(HOME)/tmsif/obj
+LIBPATH_C      = $(HOME)/com/lib
+LIBPATH_TLOG   = $(HOME)/TLogger/lib
 LIBPATH        = $(HOME)/tmsif/lib
+EXEPATH        = $(HOME)/tmsif/exe

-TARGET = $(LIBPATH)/libtmsif_trcsts.a
+CFLAGS = -fPIC -c

I also tried 'git checkout .', and File modified after git clone , git shows modified files after clone , nothing changed.

I encounter this isse on "git version 2.17.1.windows.2" (git for win), and "git version 2.37.2" (msys2).

What is really interesting is that, I don't suffer from this issue on "git version 2.37.2" (Fedora 36).

Any clues or hints? Thanks.

Upvotes: 0

Views: 140

Answers (2)

grizzlybears
grizzlybears

Reputation: 510

After abandon windows for 5 monthes, I eventually know the reason.

There are both 'makefile.Linux' and 'Makefile.Linux' in the same dir.

On linux that is OK, but on Windows they are considered as same file, so one will be overwrited by another and thus become 'modified' in git view.

What a suprise :)

Upvotes: 0

LeGEC
LeGEC

Reputation: 51912

Given the modifications, it is very unlikely that they are the result of some script editing your files.

You can have a weird behaviour in your repo if your directory is actually "handled" by a cloud syncing tool, such as ownCloud, oneDrive, google drive ...
If the cloud syncing tool chooses to restore files in your .git/ directory, you can have the notion of "active commit", for example, that changes without you being aware of it.

fix is : make sure to not work in a cloud synced directory.


If you are working in a shared drive, you can have similar effects if someone else is running actions on that directory.


You could have a script, that somehow reacts to one of your actions, and chooses to git reset your repo to some other commit.

Upvotes: 2

Related Questions