I faced weird behaviour of Git - it does not want to add certain files to repository!
Example:
git add "build-tools\build\config\r2010a\build-all.ini" "build-tools\build\config\r2011a\build-all.ini"
git status -uno
It shows - no files added! (I tried with double quotes around filenames and without - nothing changed, files are exists, checked with "type %file%" command - it correctly shows file content)
But when I do this:
git add "build-tools\build\config\r2010a\build-all.ini"
git add "build-tools\build\config\r2011a\build-all.ini"
git status -uno
It shows that these 2 files were added correctly.
Ok... I re-created the same folder & files structure, initialized new Git repository and tried the same case - problem is easily reproducible.
So, when adding 2 (or more) of such files it does not add anything at all!
Then I changed example to more simple:
git reset
git add sub1\aaa.txt sub2\bbb.txt
git status
It works fine.
Changed test case to make it more similar to original case:
git reset
git add build-tools\folder-1\sub1\build-ccc.ini build-tools\folder-1\sub2\build-ddd.ini
git status
That also works fine...
So, this command silently does not work:
git add "build-tools\build\config\r2010a\build-all.ini" "build-tools\build\config\r2011a\build-all.ini"
But very similar command works fine:
git add build-tools\folder-1\sub1\build-ccc.ini build-tools\folder-1\sub2\build-ddd.ini
Note: I also tried with other slash char and with duplicated slash - these also does not work:
git add "build-tools/build/config/r2010a/build-all.ini" "build-tools/build/config/r2011a/build-all.ini"
git add "build-tools\\build\\config\\r2010a\\build-all.ini" "build-tools\\build\\config\\r2011a\\build-all.ini"
But why??!!
I cannot find anything in documentation about such limitations for "git add".
Even if there is such limitation - that might be ok. BUT(!) there MUST BE AN ERROR MESSAGE that not all of specified files were added!!! Because currently it is silently ignoring my commands and does not add anything! So, I cannot predict cases when files might be not added to repository! :-(
Questions are:
- What exactly is wrong in this particular case? Is it possible to predict/diagnose such 'silent Git failures'?
- How to make it working with adding multiple files?
- How to make it report an error in case when "git add" fail to add some files?
Thank you.
PS. It is Windows 10 20H2 OS. git version 2.33.0.windows.2 (the latest one for the moment)
PPS. I'm doing migration from MKS to Git and such cases when Git silently does nothing are very dangerous because some changes might be lost during migration which is very bad!
PPPS. I was asked to show shell output, so here it is:
E:\sbx\mks\test1>git add "build-tools/build/config/r2010a/build-all.ini" "build-tools/build/config/r2011a/build-all.ini"
E:\sbx\mks\test1>git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
StkOverflow-GitWeird-fail to add.txt
build-tools/
sub1/
sub2/
nothing added to commit but untracked files present (use "git add" to track)
E:\sbx\mks\test1>git reset
E:\sbx\mks\test1>git add build-tools\folder-1\config\r2010a\build-all.ini build-tools\folder-1\config\r2011a\build-all.ini
E:\sbx\mks\test1>git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: build-tools/folder-1/config/r2010a/build-all.ini
new file: build-tools/folder-1/config/r2011a/build-all.ini
Untracked files:
(use "git add <file>..." to include in what will be committed)
StkOverflow-GitWeird-fail to add.txt
build-tools/build/
sub1/
sub2/
E:\sbx\mks\test1>git reset
E:\sbx\mks\test1>git add "build-tools/build/config/r2010a/build-all.ini" "build-tools/build/config/r2011a/build-all.ini" --verbose
E:\sbx\mks\test1>git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
StkOverflow-GitWeird-fail to add.txt
build-tools/
sub1/
sub2/
nothing added to commit but untracked files present (use "git add" to track)
E:\sbx\mks\test1>
E:\sbx\mks\test1>dir "build-tools\build\config\r2010b\build-all.ini" "build-tools\build\config\r2011a\build-all.ini"
Volume in drive E is VM_STOR
Volume Serial Number is xxxx-xxxx
Directory of E:\sbx\mks\test1\build-tools\build\config\r2010b
2021-09-07 09:08 12 087 build-all.ini
1 File(s) 12 087 bytes
Directory of E:\sbx\mks\test1\build-tools\build\config\r2011a
2021-09-07 12:32 11 build-all.ini
1 File(s) 11 bytes
0 Dir(s) 150 320 095 232 bytes free
It seems I found a reason of this problem:
E:\sbx\mks\test1>git add build-tools\build\config\R2010A\build-all.ini build-tools\build\config\R2011A\build-all.ini --verbose
add 'build-tools/build/config/R2010A/build-all.ini'
add 'build-tools/build/config/R2011A/build-all.ini'
E:\sbx\mks\test1>git reset
E:\sbx\mks\test1>git add build-tools\build\config\r2010a\build-all.ini build-tools\build\config\r2011a\build-all.ini --verbose
So, filenames are case-sensitive, while windows itself is not case-sensitive... So, "r2010a" and "R2010A" are different folder names. :-\
However, it is still unclear - WHY IT DOES NOT REPORT ANY ERRORS?!
So, for sure - THIS IS BUG IN GIT for Windows!!!