Your situation
I'm creating the situation you described with 3 un-pushed commits:
$ git clone <url>
$ touch file1
$ git add file1
$ git commit -m "Correct 1st commit"
$ touch file2
$ touch webstormfile
$ git add .
$ git commit -m "Wrong 2nd commit with by mistake included WebStorm file"
$ touch file3
$ git add file3
$ git commit -m "Correct 3rd commit"
$ git log --oneline
$
$ ad73bfa Correct 3rd commit
$ eddae38 Wrong 2nd commit with by mistake included WebStorm file
$ ad219bf Correct 1st commit
Removing committed WebStorm files
Beware: the following steps are going to change the history, meaning, if the commits have already been pushed, changing the history will break the repository for all team members. If you haven't pushed yet, you can follow the steps without bothering your team members.
Start interactive rebasing including the hash eddae38
of the wrong commit:
$ git rebase -i eddae38^
The text editor pops up with the following content:
pick eddae38 Wrong 2nd commit with by mistake included WebStorm file
pick ad73bfa Correct 3rd commit
# Rebase ad219bf..ad73bfa onto ad219bf
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
In the first line, change pick to edit, save the file and close the text editor.
Attention! Make a copy of your WebStorm file if want to keep it. Then, remove the WebStorm file from the commit:
$ git rm .\webstormfile
Commit the cleaned up index:
$ git commit --amend --no-edit
Finish the rebasing:
$ git rebase --continue