0

So I made a horrible mistake, I've most probably pushed node_modules before adding them to .gitignore, and now all my branches (I use gitflow) have node_modules in it.

Is there a way to dynamically delete node_modules per all branches? I can do it manually, of course, but I was wondering if I could write a git script for it.

I've found git for-each-ref, but don't really understand it that well.

I guess something like git for-each-ref rm -r --cached node_modules, but am not sure how to translate this correctly.

tachko
  • 111
  • 1
  • 7
  • Do you want to rewrite the history without node_modules and just want to do a commit to remove it on all branch put keep it into the history ? – Ôrel Jun 29 '20 at 19:08
  • preferrably, remove from history as well – tachko Jun 29 '20 at 19:10
  • All is here https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history – Ôrel Jun 29 '20 at 19:13
  • Does this answer your question? [Remove folder and its contents from git/GitHub's history](https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history) – Ôrel Jun 29 '20 at 19:13
  • I will give it a try tomorrow, seems like it. thanks – tachko Jun 29 '20 at 20:48

0 Answers0