1

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?

MeltingDog
  • 11,060
  • 34
  • 130
  • 238

2 Answers2

1

.gitignore works for files not yet added, 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.

Rusi
  • 696
  • 7
  • 16
Geno Chen
  • 3,835
  • 6
  • 16
  • 32
0

.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