英文:
What are "BIN" files on github?
问题
我想在 GitHub 上上传一些 .java 文件,我不记得我是否上传了正确的文件。有人告诉我应该提交的文件丢失了。我检查了最后一次提交,应该提交的文件被标记为“BIN”,类型为“classname”.class,而不是“classname”.java,每个文件下面都显示“Binary file not shown”,而不是代码。我想知道发生了什么,以便将来避免这种情况。我以前在 GitHub 上从未遇到过这种情况。我上传了什么?我认为在这个项目中没有任何 .class 文件。
英文:
I wanted to upload some .java files on github, I don't remember if I uploaded the right files. I have been told that the files I should've submitted were missing. I checked the last commit, and the files I should've submitted were marked with "BIN" and were of type "classname".class instead of "classname".java, underneath each one of them it says "Binary file not shown" instead of the code. I would like to know what happened so that I can avoid this in the future. I have never experienced this before on github. What did I upload? I don't think I had any .class files regarding this project.
答案1
得分: 1
/bin
通常是一个包含二进制文件或通常编译出的内容的文件夹。您永远不应将其放入存储库中。
它并不危险,但会浪费空间,而且每个人的计算机都需要单独编译它们,因此将它们放在存储库中是没有意义的
英文:
/bin
is usually a folder that contains binary files or compiled stuff in general. You should never put it in a repo.
It's not dangerous, but it wastes space and it's something that has to be compiled in each one's computer anyway, so it's pointless to put them in the repo
答案2
得分: 1
根据您所说,似乎您将不应添加的文件添加到了提交中。
要解决这个问题,只需移除这些文件,然后提交并推送更改。完成。
为了避免将来出现类似情况,不仅适用于您个人,还适用于您的团队,您可以在代码库的根目录下创建一个.gitignore
文件。这个文件包含路径模式(文件和文件夹),这样在显示分支状态时 Git 将忽略这些文件。如果没有这样的.gitignore
文件,那么请创建一个并添加以下内容:
*.class
bin/
此外,您还可以在这个文件中添加更多条目,以便省略 IDE 生成的其他文件,例如。您可以找到一些经过精心策划的列表,比如 https://gist.github.com/chhh/4961200 或 https://www.gitignore.io/api/eclipse。
英文:
From what you say seems like you added files to your commit that shouldn't be added.
Well, to fix this, just remove those files, commit and push the changes. Done.
To avoid this scenario in the future and not only for you but for your team, you can create a .gitignore
file at the root of the repository. This file contains patterns of paths (files and folders) so git will ignore those files when showing the state of the branch. If there's no such .gitignore
file then create one and add the following:
*.class
bin/
Also, you can add more entries in this file to support omitting other files generated by IDE, for example. There are curated lists you can find like https://gist.github.com/chhh/4961200 or https://www.gitignore.io/api/eclipse
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论