Reputation: 393
I have a git repo, containing the folder A
. Locally, I clone this repo, but then decide to rename that folder:
git mv A newfolder
git add -u newfolder
git commit -m "Folder rename"
Now, if I modify A/stable
in my repo, then do a git pull
locally, sure enough, I get:
newfolder/stable
However, if I create a new file in my repo, A/fresh
, and do a git pull
locally, I end up with
A/fresh
instead of newfolder/fresh
(that is, git creates a new folder named A
, and puts the fresh
file there). Why is this rename not working with new files?
Upvotes: 1
Views: 112
Reputation: 5862
Git will have no clue that A
was replaced by newfolder
. If you created A/fresh
file in a remote repo and then fetch/merge that into your local repo, it'll have no choice but to mimic the remote structure and create the folder A
.
The solution here would be to push your changes (A
becomes newfolder
) to the remote repo before you create the fresh
file. Therefore, you'd be creating newfolder/fresh
instead of A/fresh
.
Upvotes: 1