giteclipseegit

Using Eclipse, how to delete a file which has been in GitHub but should been in .gitignore file?


If a file "a.txt" has been committed and pushed to a GitHub repo but I want to ignore it now.

Using git bash, I could use git rm --cached a.txt and a new line "a.txt" in .gitignore to delete this file in the GitHub repo.

But what should I do if I use Eclipse ?


Solution

  • Eclipse allows you to mark files as Untracked by right-clicking on the file and selecting Team>Advanced>Untrack even if that file is present in the .gitignore.:

    enter image description here (I removed some unnecessary parts of the context menu)

    This will essentially do the same as git rm --cached.

    Then, the file will be marked as deleted in the Staged Changes part of the Git Staging menu:

    enter image description here

    After doing that, just commit and push the (staged) changes.

    Of course, nothing stops you from using the command-line. Even if you use Eclipse, you can still enter some commands via the command-line and do some other stuff with Eclipse/EGit.