Git ignore a specific file in Eclipse

 ̄綄美尐妖づ 提交于 2019-12-05 14:49:51

Your problem is probably that Main.java is already in your index. The solution

First make it disappear

git rm src/test/java/packageName/Main.java

then add it to your gitignore

echo "src/test/java/packageName/Main.java" >> .gitignore

now commit these changes

git add .gitignore
git commit -m "please ignore me!"

And it should work :-)

You can now recreate your Main.java and it should no longer appear in git status.

Able to achieve it in Eclipse Oxygen. Here step follows.

  1. Enable "Automatic Ignore" .ignore file from window-> preference.

  2. Right Click on file/folder to ignore. For example right click on target folder(contains .class file). Team -> Ignore

  3. Go to Staging view, you will see .ignore file generate.
  4. Right click on .ignore file and ignore that again.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!