Reputation: 2735
This happens when I try running the git cherry-pick <commit sha>
command.
git cherry-pick eaf640bd3ce9f2a4e0650a0c9b9d0fbb920a77a9
error: The following untracked working tree files would be overwritten by merge: myfile.java Please move or remove them before you merge. Aborting fatal: cherry-pick failed
Now I want to remove that file, because I don't need it anymore.
git rm myfile.java
fatal: pathspec 'myfile.java' did not match any files
But I do see the file when running git status
. If I delete it manually from disk, any time I do rm -f ./.git/index.lock
it gets recreated.
How do I remove that file permanently not having to care about it?
Upvotes: 4
Views: 4748
Reputation: 85887
The first error message says the file is untracked, i.e. it is not part of recorded history and git doesn't know about it.
git rm
gives you an error for the same reason: You can't remove files from the repo that aren't part of it in the first place.
Plain rm myfile.java
should get rid of it.
Upvotes: 1