-1

In Git bash, I deleted a folder using:

GIT RM -r folder

Then I added a different folder using:

git add . 

When I run git status, instead of "added", the new files have "renamed".
Note: The files and subfolders are almost identical.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
petercli
  • 629
  • 1
  • 8
  • 27
  • 2
    Possible duplicate of [How does Git know that file was renamed?](https://stackoverflow.com/questions/29822823/how-does-git-know-that-file-was-renamed) – Gino Mempin May 09 '19 at 00:38

2 Answers2

0

“The files and subfolders are almost identical.” Well that’s why. git sees this as a continuity; in effect you’ve merely moved the files, perhaps with some changes, to another folder. Usually that’s how people want this sort of thing to be understood by git.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

If a file has the same hash, it's considered the same file. So, even if you remove and recreate it, it's considered a rename.

And, in fact, I believe Git can also consider two files the same thing if they're only slightly different, based on how much changed in commits between the two actions (delete old and create new). Below a certain ratio, it considers it a rename-and-change rather than a delete-and-create.

What I take from this is that you shouldn't necessarily trust what Git is telling you. It's making a fairly educated guess as to what actually happened.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953