Skip to content

Git fails to track changes after renaming files #2769

Closed as not planned
Closed as not planned
@NoiseDoll

Description

@NoiseDoll
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.26.2.windows.1
cpu: x86_64
built from commit: 4267c88d0d8936ae723bba55e0576b1c4f3d4e1a
sizeof-long: 4
sizeof-size_t: 8

and

git version 2.27.0.windows.1
cpu: x86_64
built from commit: 907ab1011dce9112700498e034b974ba60f8b407
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19041.388]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Default
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Tested on two different machines with different git version. Same result and the repro is not 100% you may need several attempts to reproduce bug.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash

You need two files with content

$ cat "Lightning Booster (x1).asset.meta"
fileFormatVersion: 2
guid: 2f2681a5c7030a44995b40805d64d815
NativeFormatImporter:
  externalObjects: {}
  mainObjectFileID: 0
  userData: 
  assetBundleName: 
  assetBundleVariant: 

$ cat "Mixer Booster (x1).asset.meta"
fileFormatVersion: 2
guid: 43cbec228323ae247b0c2aa626c52a3e
NativeFormatImporter:
  externalObjects: {}
  mainObjectFileID: 0
  userData:
  assetBundleName:
  assetBundleVariant:

Then you need to rename them both in this order

$ mv "Lightning Booster (x1).asset.meta" "Shuffle Booster (x1).asset.meta"
$ mv "Mixer Booster (x1).asset.meta" "Lightning Booster (x1).asset.meta"
  • What did you expect to occur after running these commands?

I expect to see this

$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   Lightning Booster (x1).asset.meta
        deleted:    Mixer Booster (x1).asset.meta

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Shuffle Booster (x1).asset.meta

no changes added to commit (use "git add" and/or "git commit -a")

$ git diff "Lightning Booster (x1).asset.meta"
diff --git a/Lightning Booster (x1).asset.meta b/Lightning Booster (x1).asset.meta
index ccca0d8..e701fb0 100644
--- a/Lightning Booster (x1).asset.meta
+++ b/Lightning Booster (x1).asset.meta
@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 2f2681a5c7030a44995b40805d64d815
+guid: 43cbec228323ae247b0c2aa626c52a3e
 NativeFormatImporter:
   externalObjects: {}
   mainObjectFileID: 0
  • What actually happened instead?

With some chance it results in git doesn't see changes in file Lightning and assumes that it's a Mixer is renamed into Shuffle

$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    Mixer Booster (x1).asset.meta

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Shuffle Booster (x1).asset.meta

no changes added to commit (use "git add" and/or "git commit -a")

photo_2020-07-28_21-50-20

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Repro repository with is attached
SampleRepo.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions