Search code examples
gitintellij-ideacommit

"Untracked Files Prevent Checkout" except its vcs.xml


I'm trying to merge a branch with the master, so I checked out the master but now it won't let me do the merge:

Untracked Files Prevent Checkout Move or commit them before checkout .idea/vcs.xml

I can't move or delete the file, because it will disengage the VCS from this project I can't commit it because it's not an option when I try to commit I can't switch to the branch to see what I can do from that end, because I get the same error message.

How can I fix this and how can I prevent it from happening again? Do I need a .gitignore file that is set up to exclude everything from the .idea folder?


Solution

  • The branch you're trying to merge has this file checked into it, but the master branch has untracked (and possibly in .gitignore). When you're trying to merge the other branch, Git prevents you from overwriting those files because you might care about them (after all, one side has them tracked).

    You have some options:

    • Delete the file and merge, which will include the version from the branch you're trying to merge.
    • Change the branch (or have the author of the branch change the branch) to not include the file you don't want to override and make sure it's in .gitignore. If this is a file specific to a given editor, it probably doesn't belong in version control, since different people use different editors and different settings.
    • Save the file to somewhere else, merge, and then determine what to do after you see the result of the merge.