Problem I have file A. When I run a windows bat file, file A's contents get changed. git status however does NOT show the file as modified - even though I can see the changes. I am quite familiar with git, but this issue is baffling me.
More details
- The file is not being git ignored.
- git update-index --really-refresh had no effect.
- Assume unchanged is not set.
- --skip-worktree on the file is not set.
- There is no extraneous .git directory in there.
- The batch file uses windows attrib, erase, and copy functions to change the file.
- If I open the file with a text editor, change something, then save the file - git status shows my new change AND all of the changes I was expecting before (with a git diff). And after doing this, it seems to work fine for a time.
- Windows 10 and git 2.18.0
- It happens in both git bash and windows cmd git.
- My teammates are also seeing the same exact issue on similar env setups.
Any ideas? It seems like the way the batch file is modifying the file is somehow circumventing whatever git status uses to identify changed files.
Desired/Expected Behavior I'd expect git status to show me the changes after running the batch file, without me having to manual interact with the file.
Thank you.
Batch File contents It is relatively simple (I generalized vars and removed display outputs).
setlocal
cls
attrib -r %HOME%\%TARGET_FILE%
erase %HOME%\%TARGET_FILE%
copy %SOURCE_FILE% %HOME%\%TARGET_FILE%
call gradle doSomething // This runs a gradle task that changes other files. These files do not have an issue, only the ones changed using attrib, erase, copy
pause
Redacted Git Config
$ git config --list
http.sslcainfo=(removed)
http.sslbackend=(removed)
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=(removed)
user.name=(removed)
user.email=(removed)
http.sslverify=(removed)
alias.dt=difftool
alias.mt=mergetool
alias.ph=log --graph --oneline --color --decorate
alias.checkbranches=ls ./*/.git/HEAD | xargs cat
core.autocrlf=true
core.editor=vim
diff.tool=bc3
difftool.prompt=false
difftool.bc3.cmd=(removed) $(cygpath -w $LOCAL) $REMOTE
merge.tool=bc3
mergetool.prompt=false
mergetool.keepbackup=false
mergetool.bc3.cmd=(removed) $(cygpath -w $LOCAL) $REMOTE $BASE $MERGED
mergetool.bc3.trustexitcode=true
alias.dt=difftool
alias.mt=mergetool
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=(removed)
remote.origin.fetch=(removed)
branch.master.remote=(removed)
branch.master.merge=(removed)
branch.(removed)
branch.(removed)
branch.(removed)
branch.(removed)