Tianxiang Xiong
Tianxiang Xiong

Reputation: 4091

git not detecting directory moved into another directory

Given a file foo/example.txt, git doesn't seem to detect the new file when it's moved into a newly created parent directory, i.e. foo/bar/example.txt, by moving the directory.

mkdir foo/bar
mv foo foo/bar

In particular, git status shows that foo/example.txt is deleted, but not that foo/bar/example.txt is create. git status --ignored will show foo/bar as an ignored dir, even though it's not in .gitignore. In fact, even renaming the directory doesn't change its ignored status.

This doesn't happen when using git mv. I don't understand why.

This is git version 2.13.0 on Darwin C02RW05YFVH6 15.6.0.

Upvotes: 1

Views: 438

Answers (1)

eftshift0
eftshift0

Reputation: 30212

It will detect it when you git rm the old directory and git add the new one.

Upvotes: 3

Related Questions