Reputation: 1882
We are using azure devops with git repositories. The git repository of our main product shows some weird behavior as of lately. Since about three weeks, a specific (project) file in the repository is not present after checking out branches based on a specific dev branch. When I take a look at the repository, the file is actually present in the repository.
We first encountered the behavior during the pull request builds. The builds failed because it said it could't find the specific file, even though the file is present in the branch. Making a change to the file by adding a space somewhere temporarily fixes the problem.
More recently, I discovered the same file sometime appears as a pending delete change on my local development pc as soon as I switch to some branches, even though I never deleted the file.
I've already tried removing the file, committing that, and restoring the file in a new commit, but the issue doesn't seem to go away.
I've already run git fsck
, and it only returns some dangling objects
Does anyone have any clue as to what is going on here?
Update:
We've had it happening again. git ls-files
only lists 25 files on the agent with the issue. When running the same command on the local repo it returns a list that seems to be the complete file list of the repo. The interesting thing might be that the file that keeps disappearing IS one of the 25 files listed on the agent. When switching to a different branch, the file re-appears. I've double checked, and the file is NOT removed in the branch it is not shown in. Futhermore, when switching from the merge branch back to the source branch, and re-switching to the merge branch, the file does NOT dissappear. Any thoughts?
Note: removing the file. Committing that, re-adding the file and removing a space, and committing that -> fixed it again (probably temporarily)
Upvotes: 0
Views: 109
Reputation: 78673
You have not given us enough information to identify the problem with certainty, but this detail:
More recently, I discovered the same file sometime appears as a pending delete change on my local development pc as soon as I switch to some branches, even though I never deleted the file.
suggests that you have checked in two files with names that differ only in case.
Run this command in git bash (substituting filename
for the actual name of the project file):
git ls-files --stage | grep -i filename
I suspect that you will see more than one entry listed, for example:
100644 a5675676e903973a412f7aaa0a07ad45f586c02b 0 filename
100644 db0cc477c38714c4ee77b0bf462a7b7156a066a2 0 FileName
This has occurred because git stores filenames case sensitively, while Windows stores files case insensitively (but case preserving). Either somebody on a platform that is also case sensitive has added a file with a similar name (that differs only in case) or somebody has erroneously changed the value of core.ignoreCase
in the mistaken belief that it is a configuration setting (it is not, it is cached information about the local filesystem and changing it will cause problems like this).
To fix it, run git rm --cached
on the various filenames, then run git add
on the correct filename. For example:
git rm --cached filename
git rm --cached FileName
git add filename
And use git log
to determine which of your colleagues has mistakenly changed their git configuration and ensure that they don't do this again.
Upvotes: 1