Chinese characters in gitignore

落爺英雄遲暮 提交于 2020-02-08 09:32:39

问题


I am using git for bunch of my java projects. I want to ignore .classpath, bin, .gradle and bunch of other files and folders.

I cannot access this files / folders in eclipse to ignore them from eclipse. Hence I decided to edit the .gitignore file. The file contains random chinese characters.

I still went ahead and updated the .gitignore file with the required file list. However, when I ignore any other file from eclipse, the .gitignore is again appended with chinese characters.

Is this expected behavior? How do I add files like .classpath, bin and others to gitignore?


回答1:


I fixed this issue. It was an encoding issue. The .gitignore file was created by someone else. I don't know what editor / platform was used to create the file.

I am using eclipse on windows. I had tried opening the file in eclipse editor / notepad / notepad++. All I could see is chinese characters. Even if I added a new file to .gitignore from eclipse (Rt Click --> Team --> Ignore), the file was appended with more chinese characters.

I changed the encoding of the file from "Default" to US-ASCII / Cp1252. I am seeing the expected data now. I can edit this file in notepad and adding new files from eclipse also gives expected results.

UPDATE:

To view .classpath, bin, build, .gradle and other such files and folders in eclipse package explorer, click on the small arrow in the top right of the package explorer. Select "Filters" from the drop-down menu. Select / deselect the filters.




回答2:


AFAIK .gitignore opened in the simpliest notepad shouldn't have any "chinese characters", should be plain text. Maybe you have a different font set up in your notepad or something? Here you can see some examples of how it should look How do I ignore files in a directory in Git?



来源:https://stackoverflow.com/questions/32208246/chinese-characters-in-gitignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!