Search code examples
gitgitignore

Delete multiple files from github windows


I committed several file changes without adding some files to .gitignore that I didn't want to include.

I added those files to .gitigonre (.npy and few .png)file and committed but files didn't remove.

How can I remove these files from all commits? if not possible from all commits I'm happy to a new fresh but a clean commit.

My repository screenshot


Solution

  • If you are fine removing commit history then simply delete those files which you didn't wanted to include and make another commit.

    Once done, rebase all commits (Avoid this step if you don't want to clear commit history).

    Add those files to .gitignore to avoid pushing them again.

    Steps you should follow for adding files to .gitignore

    1) Add files which you don't want to commit in .gitignore file

    2) Commit .gitignore file and push the changes

    Next time, you won't see any of those file while making a new commit.

    Let me know if you still face the issue!