What type of files to commit versus ignore in a Git repository?

左心房为你撑大大i 提交于 2019-12-11 16:46:57

问题


So I want use both GitHub and Bitbucket as repos (depending if I want something to be public versus private) and a lot of my work also includes LaTeX work (so there are .tex, .png, and .pdf files) as well as speed tests (so I may have .csv, and .Rdata files).

I'm having a hard time determining what kinds of files should make their way into my repos versus which should be linked to inside the README.mds.

Does anyone have any simple philosophies or hard-and-fast rules they'd like to share?


回答1:


Generally ignore binary files, and especially large files. Git doesn't do large or binary file tracking with aplomb like SVN can.

If you must, exceptions can be made for small files (i.e. png's) as long as they aren't changing too much.




回答2:


Typically you'll want your repo to contain only files from which everything else can be automatically generated.

For example, if it's a C program, you'll want *.c and *.h files, plus any Makefiles, but not object files and executables. The idea is that someone can clone your repo, follow your build instructions, and recreate everything needed to use your project.

Text vs. binary is not always the best rule to follow. For example, a .png image file that's generated automatically doesn't need to be in the repo, but if it's an icon file that you built manually (and that your program depends on), it should be in the repo.

This isn't a hard and fast rule. Sometimes it might be convenient to include generated binaries. For example (assuming an application), if you package the installable application into, say, a .zip, .tgz, or .msi file, it's reasonable to provide that in the repo (probably in a separate directory). If you include something like that that's intended to be the current version of the application, be sure it's up to date before you commit and push.



来源:https://stackoverflow.com/questions/21067051/what-type-of-files-to-commit-versus-ignore-in-a-git-repository

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