pbattisson
pbattisson

Reputation: 1240

Cannot checkout branch after doing a git rm

I just made the following change

git rm -r --cached myProject/build/*

and pushed the change into my remote repository. I did this on a feature branch called story1. When I try to checkout my development branch (which this branched from) I get the error

error: The following untracked working tree files would be overwritten by checkout:

and a list of file in the directory myProject/build.

Any ideas on how I fix this?

Thanks

Upvotes: 0

Views: 308

Answers (1)

Paweł Obrok
Paweł Obrok

Reputation: 23174

You have only removed the files from the index without removing them from your working copy. The second branch still has those files hence the message. You can use

git checkout --force [branch]

to overwrite local changes with whatever is in the branch. Or you can just delete the contents of myProject/build.

Upvotes: 2

Related Questions