Symptoms
I have a strange issue where I want to checkout a different branch <branch2>
, but when I try I get the message that
$ git checkout <branch2>
error: The following untracked working tree files would be overwritten by checkout:
<filename.xlsx>
Please move or remove them before you switch branches.
Aborting
However git ls-files
lists <filename.xlsx>
as a tracked file.
Workaround
If I do a git checkout -f <branch2>
it works, and the <branch2>
version of the excel file is present and correct (similarly if I rm <filename.xlsx>
and then checkout I get the correct file.)
To move back to <branch1>
I get the exact same issue (<filename.xlsx>
is tracked, but for checkout appears to be untracked).
Testing/Troubleshooting
Investigating further this seems to be related to a Windows/Linux issue:
- I work predominantly in a VirtualBox VM of Debian, so I use my git tooling and terminal there, and access via a VirtualBox shared folder.
- Some of my code (this repository included) lives on the host system (Windows 10) as it is platform specific.
- If I use Git for Windows this issue does not occur.
- If I clone to a linux filesystem this issue does not occur.
- If I clone from upstream to a different Windows folder and access from linux I get the same issue.
- Other branches in the same repository that have the same file with different contents again do not suffer from the same issue (ie checkouts work as expected)
- Other commits with the same version of the file have the same issue.
- A small repo with just these two file versions does not exhibit the same behaviour, so, unfortunately, no easy way to create MCVE.
Final Thoughts
Honestly, it is something that is relatively easy to work around, and seems limited in scope so far to only these two copies of the , but it has me intrigued. If anyone with greater knowledge of git has any ideas on how to diagnose/fix the root cause of this issue I would be very grateful.
Extra debugging
Here is the results of git ls-files --debug
from <branch1>
CodeSheet.xlsx
ctime: 1489465633:751038200
mtime: 1489465633:751038200
dev: 38 ino: 5432
uid: 0 gid: 999
size: 14752 flags: 0
Here is the results of git ls-files --debug
from <branch2>
Codesheet.xlsx
ctime: 1489467487:720851100
mtime: 1489467487:720851100
dev: 38 ino: 5502
uid: 0 gid: 999
size: 12546 flags: 0