6

When I open the Commit Changes Dialog (Ctrl + K) in WebStorm, it selects all changed/added/removed files. I'd like to avoid accidentally committing files. And often I uncheck all files and then check those files that I want to commit.

Is there a way to disable auto-selection of all files by default in the Commit Dialog (I didn't find such option in the settings)?

traxium
  • 2,701
  • 2
  • 16
  • 17
  • 1
    This means you don't want to commit most of the files you changed? May I know the reason? Feature wise it is pretty much logical to auto select all the changed files. So I don't think there's such option to disable it. – Supun Wijerathne Dec 06 '16 at 08:36
  • 1
    In addition to what @SupunWijerathne is saying, you could maybe use [changelists](https://www.jetbrains.com/help/idea/2016.3/changelist.html) to track only the files you want to commit. You can have multiple [such lists](https://lh6.googleusercontent.com/-_pHlmE4YwCY/VHhyLfO2yYI/AAAAAAAAPNc/yaYfsZcKKm8/78-changelist.gif) (even a _do not commit_ one) while one of them is active, then choose whatever you want to really commit. Also, from the upper-right corner of the commit dialog, you can switch the changelist you want to see – Morfic Dec 06 '16 at 12:28
  • 1
    @SupunWijerathne, usually I don't want to commit only one or two files that are not yet ready to be committed, and I have to uncheck them every time I do a commit. E.g. I keep track of all changes in changelog.txt and I make a notice in it that some issue was fixed (but in reality I'm only going to fix that issue) and it requires several commits to fix that issue. And I do not want to commit changed changelog.txt until the issue is indeed fixed, so I have to uncheck changelog.txt each time I do a commit except the very last commit for the issue. – traxium Dec 06 '16 at 18:17
  • 1
    @traxium there are 2 points regarding your requirement. (1) If you want to commit most of the files except one or two, the easier way would be unchecking the unwanted rather than checking the wanted, because #0f cliks would be less. So you don't need to disable it. (2) if that changelog.txt thing would not be committed at all, you can make use of "gitignore". :)) – Supun Wijerathne Dec 07 '16 at 03:27
  • 1
    @SupunWijerathne, the point is that if I'm unchecking one file every time I do a commit, I will certainly forget to uncheck it once out of 100 commits. If everything is unchecked by default there's nothing to forget, it's less error prone approach. And it doesn't matter that I have to do one more click because it's much more important that I'd feel myself more comfortable when I'm not afraid of forgetting to uncheck one file. – traxium Dec 07 '16 at 19:24
  • @traxium yes your point makes sense. So you can use "gitignore". So that file will be automatically unchecked every time. :)) – Supun Wijerathne Dec 08 '16 at 01:09
  • 3
    @SupunWijerathne `.gitignore` has no effect on what's selected in the commit dialog, your last comment is wrong. And besides, `.gitignore` file is only for unversioned files. – traxium Mar 17 '17 at 05:20
  • 1
    Often i want to commit changes of files one by one, therefore this would be a nice feature... – goulashsoup Sep 11 '19 at 08:39

1 Answers1

1

Since you said in the comments that you really wanted to not select one particular file by default, changelog.txt, you can tell Git to ignore changes to that file, and then hopefully WebStorm will not detect the changes either.

There are two similar features for ignoring changes to a file in Git: --assume-unchanged and --skip-worktree. See Git - Difference Between 'assume-unchanged' and 'skip-worktree' for the difference. You probably want --skip-worktree.

You can use it in your case like this:

git update-index --skip-worktree changelog.txt

Now git status won't include your change to changelog.txt in its list.

When you're finally ready to actually commit the change, run

git update-index --no-skip-worktree changelog.txt

The comments of http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html suggest some aliases to make the above commands easier to run, although that article only discusses --assume-unchanged, not --skip-worktree.

Community
  • 1
  • 1
Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
  • Actually, I started to use [Changelists](https://www.jetbrains.com/help/idea/2017.1/changelist.html) and it helps to solve my problem. – traxium Apr 21 '17 at 13:54