简体   繁体   English

如何在GitHub中组织和分类小项目?

[英]How to organize and categorize small projects in GitHub?

I'm new to development and trying to upload small projects that I've worked on to my GitHub profile. 我是开发新手,并尝试将我已经处理过的小项目上传到我的GitHub配置文件中。 These projects are not dependent on each other. 这些项目并非相互依赖。

My issue is that some of them are small single-file projects. 我的问题是其中一些是小型单文件项目。 Sort of like mini challenges that I've solved. 有点像我已经解决的迷你挑战。 So I'm thinking of grouping them together under one repo called "Python programming", for example. 因此,我正在考虑将它们组合在一个名为“Python编程”的repo中。

Is this a good practice? 这是一个好习惯吗?

  • If yes, how should I go about it in Git, and how can I still have a README file showing up for each mini project. 如果是的话,我应该如何在Git中使用它,我怎样才能为每个迷你项目显示一个README文件。

  • If no, what would you recommend doing? 如果不是,你会建议做什么?

GitHub will render a README file for every folder you visit, so when using just a single repository, one solution would be to still create one sub folder for each “subproject” that as such can have its own README file. GitHub将为您访问的每个文件夹呈现README文件,因此当仅使用单个存储库时,一个解决方案仍然是为每个“子项目”创建一个子文件夹,因此可以拥有自己的README文件。

But before going that route, you should think about if those small projects actually belong together. 但在走这条路之前,你应该考虑一下这些小项目是否真的属于一起。 That's ultimately what should decide whether you want to put them all in the same repository or whether you want to split it up into several repositories. 这最终应决定是否要将它们全部放在同一个存储库中,或者是否要将其拆分为多个存储库。

Some things to consider for that decision: 该决定需要考虑的一些事项:

  • If the projects do not depend on another, do they still relate to another? 如果项目不依赖于另一个项目,它们是否仍然另一项目相关? For example, are those projects part of a bigger programming challenge like Project Euler and you're just collecting all your solutions? 例如,那些项目是Project Euler等更大的编程挑战的一部分吗?您只是收集所有解决方案? Then a single repository might make more sense. 然后单个存储库可能更有意义。
  • What is the chance for individual projects to grow into bigger things? 个别项目成长为更大的东西的机会是多少? Many things start very small but can eventually grow into real things that justify their own repository. 许多事情从很小的事情开始,但最终可以发展成为他们自己的存储库合理的真实事物。 At that point, you might even get others to contribute. 那时,你甚至可能会让别人做出贡献。
  • Does it make sense for those individual files to share a history? 这些单独的文件共享历史记录是否有意义? Are the files even going to be edited once they are “done”? 文件甚至会在“完成”后进行编辑吗? Ie is this just a collection of finished things, or are they actually ongoing experiments? 即这只是成品的集合,还是他们实际上正在进行的实验?

Ultimately, it comes down to your personal choice. 最终,它取决于您的个人选择。 But GitHub, as the repository hoster, should not be driving your decision. 但作为存储库主机的GitHub不应该推动你的决定。 You should create Git repositories locally as it makes sense to you. 您应该在本地创建Git存储库,因为它对您有意义。 If that means you just have a single one, that's fine. 如果这意味着你只有一个,那很好。 If that means you create lots of them, that's also fine. 如果这意味着你创造了很多,那也没关系。

Unfortunately, the GitHub UI is not really made for small one-off projects. 不幸的是,GitHub UI并不是真正用于小型一次性项目。 The repository list is just to unorganized for that. 存储库列表只是为了无组织。 If you decide to use small projects, I advise you to add some prefix for categorization within your GitHub profile, so you know what this is about. 如果您决定使用小项目,我建议您在GitHub配置文件中添加一些分类前缀,以便了解这是什么。

A good alternative for one-off projects, especially when it's just a single (or a few) files are Gists . 一次性项目的一个很好的替代方案,特别是当它只是一个(或几个)文件时是Gists Gists are born as a way to share code snippets but under the hood, every Gist is actually a full Git repository. Gists作为一种共享代码片段的方式而诞生,但在引擎盖下,每个Gist实际上都是一个完整的Git存储库。 Of course, Gists do not offer the tools normal repositories on GitHub have (eg issues, pull requests, wikis). 当然,Gists不提供GitHub上的正常存储库工具(例如问题,拉取请求,维基)。 But for what you describe, you probably need neither of those. 但是对于你描述的内容,你可能不需要那些。 Then, Gists are a fine way to share simple things without adding full repositories to your profile. 然后,Gists是分享简单事物的好方法,无需在配置文件中添加完整的存储库。 And you can still clone them (the remote URL is git@gist.github.com:/<gist-id>.git ) and have a full history and support for multiple files if you need those. 您仍然可以克隆它们(远程URL是git@gist.github.com:/<gist-id>.git )并且如果您需要,可以获得完整的历史记录和对多个文件的支持。

Commonly, you'll see that the top level of the repo contains the README file, maybe a setup.py and some other extraneous information, and perhaps a tests folder. 通常,您会看到repo的顶级包含README文件,可能是setup.py和其他一些无关的信息,也许还有一个tests文件夹。 Then there will be a folder that shares a name with the repo. 然后会有一个与repo共享名称的文件夹。 Inside of that folder is the code that's intended to be core content of the module/package/script. 该文件夹内部的代码是模块/包/脚本的核心内容。

It's also not unusual to see different organization, particularly with very small projects of single-file scripts. 看到不同的组织也是不寻常的,特别是对于单文件脚本的非常小的项目。

For the specific case you mention, do whatever you like. 对于你提到的具体情况,做你喜欢的事。 What you propose sounds totally reasonable to me. 你提出的建议对我来说听起来很合理。 I would not want to have a separate repo for all the challenges I solve! 对于我解决的所有挑战,我不想单独回购!

I usually use a gist for trivial items I don't necessarily want to make a repo for, including coding challenges. 我通常使用一个要点来处理我不一定想要回购的琐碎项目,包括编码挑战。 So I would offer that as an alternative. 所以我会提供这个替代方案。 Do whatever suits you best. 做任何最适合你的事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM