1

In IntelliJ when using Git Branches, I normally have received a prompt asking me to commit changes before changing branches. However, now this prompt is not showing anymore, resulting in some annoying issues when I forget to commit.

I have looked through the settings to no avail, hope someone knows how to fix this.

Arne O. Ose
  • 63
  • 1
  • 7
  • 1
    This is the default behavior of Git, at least in recent versions. You will still be prompted if switching branches would force Git to overwrite/remove some of the changes in your working directory. Best practice basically states that you should switch branches when your working directory is dirty. Instead, commit, stash, or reset, then switch. – Tim Biegeleisen Jan 03 '19 at 13:39
  • With command-line git, there are some cases where you get a warning and some where you don't. It depends whether the checkout is "safe" in terms of preserving the uncommitted changes. That's been the case as long as I can remember, so I wonder if what you're seeing is really a change in behavior, or if it's just that you remember cases where changes would be lost whereas in recent cases they would not? IDEA does throw another variable into the mix; maybe they've changed something. But I suspect it's otherwise. – Mark Adelsberger Jan 03 '19 at 14:33
  • Hehe, well better than it deleting those things without warning, which IntelliJ also does.. sometimes.. – nsandersen Feb 21 '22 at 13:56

1 Answers1

2

IntelliJ relies on command line git and shows a warning with the Smart checkout option only when git reports some conflict on checkout.

If git reports no conflicts - there is no warning in the IDE, and the branch is switched, keeping your uncommitted changes in the working tree. As noted in comments, it is default git behavior

Dmitrii Smirnov
  • 7,073
  • 1
  • 19
  • 29
  • Is there a way to not carry the changes over to the working tree without committing or stashing? Probably the closest thing might be some kind of automatic stash on checkout and automatic unstash when coming back on that same branch. – payne Apr 03 '20 at 03:32
  • 1
    No at the moment. https://youtrack.jetbrains.com/issue/IDEA-90151 – Dmitrii Smirnov Apr 03 '20 at 12:00