Reputation: 15404
I made a mistake and mispelt the name of my .gitignore file and when I went to push up to Github I realised I was also pushing up everything in my node_modules
directory. I cancelled the command (ctrl + c) and fixed the .gitignore and ran git rm -r --cached .
.
Running git status
then showed only the changes to my .gitignore file so I commited them and then when to push up. However, during the git push
I noticed the node_module
files were still being pushed up.
Again I cancelled the command (ctrl + c) and ran git reset --hard HEAD^
, re-added and re-committed, but again it seemed I was pushing up the node_module
files.
Becuase I cancelled the push part-way through these files seem to be stuck in limbo.
Is there some way I can fix this so I can merge to github without pushing up my node_module
files?
Upvotes: 1
Views: 1002
Reputation: 5214
.gitignore
works for files not yet add
ed, but not for files that are already tracked.
You may have to use git filter-branch
to remove those files from your Git local history.
After that, a force push is needed, because you have modified the history.
Upvotes: 2
Reputation: 507
.gitignore wont work for files or folders that are already pushed (inside a branch); edit git ignore directly in repo, delete files, and then pull to local; remove files in local
Upvotes: 0