Refactoring prevent auto staging to git

Answered

I'm refactoring a Java class by renaming it, Intellij will, after the rename, stage the file automatically.
I do not want this behavior. In fact I want Intellij never to touch the staging area at all. I prefer to do
this manually, how do you do this?

2
2 comments

It is not possible, IDE always executes both git rm and git add on rename/move. Not staging a rename will prevent correct rename detection in git, and Local changes will show deletion + an Unversioned file instead. This will be unexpected and likely considered a bug by a lot of users. So there are no plans to change this particular behavior. See https://youtrack.jetbrains.com/issue/IDEA-176961

> In fact I want Intellij never to touch the staging area at all

Introducing a "read-only" mode preventing IDE from doing any write operations could help. Vote for https://youtrack.jetbrains.com/issue/IDEA-194592

0

The above doesn't quite describe how this operation works in git. Git's own git mv command does stage a remove and add of the file, but the added file is the previously staged version ("from the index"), not the version from disk.

Because of this, `git mv` preserves exactly which content changes were staged and which were not, but IDEA's behaviour loses the previously staged state, and any temporary or unfinished changes in that file bypass the review process, and often get committed by accident.

0

Please sign in to leave a comment.