1

I was trying to make a commit when I noticed that there is a file in the working directory, that I didn't change and it has the wrong first letter in folder name:

Changes to be committed:
        new file:   "\txample/src/Example.Repository/Services/Authentication/IAuthenticationService.cs"

Changes not staged for commit:
        deleted:    "\txample/src/Example.Repository/Services/Authentication/IAuthenticationService.cs" 
        modified:   Example/src/Example.Repository/Database/EquityOrder.cs    <-- correct folder name

My "IAuthenticationService.cs" file was never changed, but still appeared in 'git status' and had the wrong folder name, which should be "Example" instead of "\txample".

I tried to discard changes to this file using 'git checkout HEAD -- filename'. When I used the wrong folder name (\txample) with 'git checkout', it didn't find that file, but using the correct folder name (Example) worked without error. But still, this file didn't disappear from 'git status'

I tried to list all the files in the tree, using 'git ls-tree' and found that a path with an incorrect folder name exists there.

While 'git status' shows that there is a change only to one file, creating a commit with this incorrect path deletes a ton of files and creates a ton of files in a pattern that I cannot understand.

 create mode 100644 Example/src/Example.Repository/ReflectionHelpers.cs
 .....
 create mode 100644 Example/src/Example.Repository/ReflectionHelpers.cs
 .....
 create mode 100644 Example/src/Example.Repository/ReflectionHelpers.cs
 .....
 delete mode 100644 Example/src/Example.Repository/ReflectionHelpers.cs
 ... (same for other files)

I cannot really understand why this is happening and how this can be fixed. Thank you for your help in advance

OS is Windows 10, using Git Bash

  • 1
    Note that `\t` is a way to encode, for visibility, a literal TAB character, sometimes made by pressing the `I` key while holding the CTRL key down (whether your TAB key actually puts in a literal tab character depends on what's interpreting your keystrokes: most browsers take it to mean "move to a different input area" rather than "add a tab character"). It seems likely that you managed to rename something while holding down CTRL a little too often—probably from trying to press SHIFT. – torek Jul 15 '21 at 09:35

1 Answers1

0

Using a similar technique as the one I mentioned in "Remove a file with a strange name from git", try, using git bash:

git mv $(printf "\txample") "Example"
# or
git rm --cached -- $(printf "\txample/")

See if renaming or deleting the "wrong" folder would at least make any file accessible again.

The OP refers to "Unstaged changes left after git reset --hard"

  • git rm --cached -r .
  • git reset --hard

Again to use with care (that would delete any work in progress)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250