How to move some files from push list?
Answered
I was pushing a set of files to repository, and then realized that some data directory contains large files so I added :
src/main/resources/ngrams
to my .gitignore file, so that I want this directory to be excluded from the commit-push list. However, since I am already in the stage of being pushing, how can I take this directory out from the 'push' list, which is pending? Please see my screen shot. Thanks.
Please sign in to leave a comment.
First of all, it is only possible to ignore files that are not tracked by git. So for the ignore to become effective, you need to stop tracking the src/main/resources/ngrams in git, which can be done by git rm --cached src/main/resources/ngrams command.
But ignoring the files will not remove them form th push list, cause you are pushing commits (e.g. changes to files) but not the files themselves. So you need to edit the history of your project and exclude the unwanted files from the commits. You could reset your local repository to some earlier revision and re-do commits without the ignored files, or use interactive rebase. See https://www.jetbrains.com/help/idea/using-git-integration.html#d858913e3726
Dmitriy:
Is there a way to do git rm --cached /src/main/resources in IntelliJ directly, instead of command line? I got used to IntelliJ.
No, IDEA uses git commit --only command, thus it is not possible to commit rm --cached from the IntelliJ. See https://youtrack.jetbrains.com/issue/IDEA-138847
Just revert the commit/commit&push you made @lingvisa by dropping down to terminal line and submitting:
git reset --soft HEAD~1
You'll then be able to re-issue commit after removing said directory :-)