23

When I try to checkout another branch, I get this error:

error: Your local changes to the following files would be overwritten by checkout:
        .idea/workspace.xml
Please, commit your changes or stash them before you can switch branches.
Aborting

I did some research and it seems some people avoided this problem by adding the afformentioned file to gitignore.

Is this a wise thing to do? If git is ignoring your workspace.xml file, won't it mess up your experience in the IDE (in my case, Jetbrains Webstorm)?

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
  • I have all the folders in gitignore `.idea/`, also the NetBeans metafiles and all metafiles in general. The *experience in the IDE* is globally saved afaik, not on a per project basis. If you are unsure, you can move the workspace.xml to your desktop, and test how it effects your experience. – Daniel W. Dec 25 '14 at 14:09

1 Answers1

33

Based on JetBrains you should not place the workspace.xml and tasks.xml in repo, as they contain user specific settings.

Pran
  • 3,481
  • 2
  • 25
  • 27
  • But will that make my workspace change strangely if I hop between commits or branches? – CodyBugstein Jan 01 '15 at 14:02
  • 1
    I never had an issue, then again, in most cases, I add .idea folder in the gitignore as not everyone in the team uses intellij. I just gave you the link to the official/recommended practice. – Pran Jan 02 '15 at 14:49
  • @Imray - It could cause issues if the files change a lot between branches\commits, but webstorm should be able to handle this (please file an issue w/ jetbrains if you find that it doesn't). OTOH, this saves you from having to do a merge on workspace.xml every time you fetch someone else's changes (which could cause more issues if merged incorrectly). – jt000 Jan 03 '15 at 16:53
  • So, if it's a private repo that only **I** am going to use it, is it no problem if I add it? – M.K Apr 26 '19 at 11:03