我什么时候应该为我的项目创建存储库?

发布于 2024-12-09 07:08:38 字数 434 浏览 0 评论 0原文

我一直在研究使用 Mercurial 进行版本管理并想尝试一下。我计划自己做一个项目来帮助我从 Java 学习 C++,并认为尝试使用它进行版本管理是个好主意。它可能是一个游戏或某种简单的应用程序,不确定是否有 GUI。

问题是我对版本管理不太了解。在项目中什么时候是创建存储库的好时机?我应该立即做吗?我应该多久进行一次提交?

我将使用 Netbeans 进行开发,因为它看起来相当不错,还内置了 Mercurial 控件,但是我应该在我的项目的 .hgignore 中设置什么?我假设存储库是 Netbeans 创建的整个文件夹,但我应该让它忽略什么?

额外问题:我将使用 Bitbucket 进行托管/备份,我应该公开该项目吗?为什么/为什么不呢?这也会使其开源吗?我应该费心附加许可证吗?因为我不知道许可证如何运作等等。话又说回来,我真诚地怀疑我是否会做出任何人都想复制的东西。

I've been looking into using Mercurial for version management and wanted to try it out. I'm planning on doing a project on my own to help me learn C++ coming from Java and thought it would be a good idea to try version management with it. It would probably be a game or some sort of simple application, not sure with a GUI or not.

The problem is I don't know much about version management. When in a project is a good time to make the repository? Should I just do it right away? How often should I make commits?

I'll be using Netbeans for my development since it seems to be pretty good, also has Mercurial controls built in, but what should I set in the .hgignore for my project? I assume the repository would be the whole folder Netbeans creates but what should I make it ignore?

Bonus questions: I'll be using Bitbucket for hosting/backup, should I make the project public? Why/why not? Also would that make it open source? Should I bother with attaching a license? Because I have no idea how the licenses work and such. Then again, I sincerely doubt I'll be making anything anyone will want to copy too badly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乞讨 2024-12-16 07:08:38

关于存储库:

您应该尽快使用 VCS 存储库。它不仅允许异地备份,还允许您跟踪更改。找出错误何时被引入。

拥有 VCS,特别是像 Mercurial 这样的分布式 VCS,将改变您的编码方式。您不必小心不要破坏东西,因为您总是有可以恢复到的旧版本。如果几周或几个月后,您认为某个特定的开发过程是一个坏主意,您可以一路倒回到之前的某个点。

通常,您应该每天或每次完成任务时都做出承诺。比如,您可能有一个 4 小时的任务“编写这个类并让它工作”。之后你就承诺了。当你完成一天的工作后,你就做出了承诺。不过,我不建议在非编译状态下提交,因此您应该尝试仅在一切仍在构建时停止。

至于忽略,你应该忽略你不打算犯的事情。您在仓库中不想要的东西。生成的文件、临时文件以及您不需要的东西。

存储库中应该包含从头开始构建项目所需的 100% 信息(减去外部依赖项)。

关于许可证:

我想说,在没有附加某种许可证的情况下建立公共存储库是非常粗鲁的。如果没有许可证,这意味着任何人在没有获得您直接、明确的许可的情况下,即使从存储库中提取内容(这是您通过公开它来邀请的),也会侵犯您的版权。

因此,要么看看版权是如何运作的,然后选择一个许可证来发布你的东西,要么将你的存储库保密。

On repos:

You should use a VCS repository as soon as possible. Not only does it allow for off-site backups, but it allows you to track changes. To find out when a bug was introduced.

Having a VCS, particularly a distributed VCS like Mercurial, will change the way you code. You won't have to be careful not to break things, because you always have the old version that you can revert to. If, after a few weeks or months, you decide that a particular course of development was a bad idea, you can rewind all the way back to some prior point.

You should generally commit either every day, or every time you finish a task. Like, you might have a 4-hour task of "write this class and get it working". You commit after that. When you're done for the day, you commit. I wouldn't suggest committing in a non-compiling state, though, so you should try to stop for the day only when everything still builds.

As for ignoring, you should ignore things you don't intend to commit. Things that you wouldn't want in the repo. Generated files, temporary files, the stuff that you wouldn't need.

What should be in the repo is 100% of the information necessary to build the project from scratch (minus external dependencies).

On licenses:

I would say that it is very rude to put up a public repository without some kind of license attached. Without a license, that means that anyone even pulling from the repo (which is what you're inviting by making it public) is a violation of your copyright without direct, explicit permission from you.

So either look at how copyright works and pick a license to release your stuff under, or keep your repos private.

无言温柔 2024-12-16 07:08:38

通常是在你想到它的那一刻。立即将您拥有的所有内容放入 VCS 中不会受到任何惩罚,谁知道呢,您可能会在以后想要那个超级原型版本。除非您要签入大型媒体文件(不要),否则我的答案是:现在。

至于多久提交一次,这是个人喜好。我使用 git,就我而言,每次进行重大更改时都进行签入没有问题。一路上拥有的快照越多,以后追踪错误就越容易。

您的 .hgignore 取决于您。您需要决定对哪些内容进行版本控制,对哪些内容不进行版本控制。根据经验,编译过程中生成的任何文件可能都不应该被签入。

此外,如果您向公众发布它,请附上许可证。它是什么并不重要,但是当世界上所有的老板和律师知道他们可以用你的代码做什么和不能做什么时,他们都会很高兴。最后,请不要向公众发布某些内容,除非您认为其他人会从中受益。互联网已经遭受信息过载的困扰。

The instant you conceive of it, usually. There is no penalty for putting everything you have into a VCS right away, and who knows, you may want that super-duper prototype version later on down the road. Unless you're going to be checking in large media files (don't), my answer is: right now.

As for how often to commit, that's a personal preference. I use git, and as far as I'm concerned there is no problem with checking in every time you make some unit of significant change. The more snapshots along the way you have, the easier it becomes to track down bugs later on.

Your .hgignore is up to you. You need to decide what to version and what not to. As a rule of thumb, any files generated during compilation probably shouldn't be checked in.

Also, if you release it to the public, please attach a license. It doesn't matter what it is, but it makes all the bosses and lawyers in the world happy when they know what they can and can't do with your code. Finally, please don't release something to the public unless you think someone else will benefit from it. The internet already suffers from information overload.

浅浅 2024-12-16 07:08:38

尽早承诺,并经常承诺。

使用 hg 或 git 等分布式 VCS,在编写任何代码之前确实没有理由不启动存储库。如果您决定废弃您的项目,您可以随时删除您的存储库,然后再将其发布到您正在使用的任何托管网站。你投入的次数越多,以后就越容易找出搞砸的地方(你会的)。

要放入忽略文件中的内容是构建文件以及 IDE 定期生成的任何内容,例如用户首选项和标记缓存。您不想将自己的偏好强加给其他人,也不想每次更改 IDE 中窗口的位置时都必须创建提交。存储库中的内容应该是某人能够处理您的项目所需的最少内容。

如果您只是做一个小项目来学习,那么我不会担心许可证或拥有私人存储库。您以后随时可以添加许可证。或者,只需选择一个宽松的许可证并使用它即可。

Commit early, and commit often.

With distributed VCS like hg or git there's really no reason not to start a repo before you even write any code. If you decide to scrap your project, you can always delete your repo before you post it to whatever hosting site you're using. The more often you commit, the easier it will be to hone in on where you messed up later on (you will).

Stuff to put in your ignore file would be build files and anything that your IDE generates periodically, like user preferences and tag caches. You don't want to foist your preferences on someone else and you don't want to have to create a commit every time you change the position of a window in the IDE. What's in the repo should be the minimum that someone would need to be able to work on your project.

If you're just doing a small project to learn, then I wouldn't worry about licenses or having a private repo. You can always add a license later. Alternatively, just pick a permissive license and go with it.

天暗了我发光 2024-12-16 07:08:38

根据我使用 git 的经验,我建议如下:

  1. 与项目一起创建存储库。
  2. 尽可能频繁地提交并提供详细的注释
  3. 当您想测试新想法时 - 创建一个分支。如果想法成功,请将代码合并到主分支。如果这个想法不成功,你可以直接丢弃该分支。也许这是最重要的想法。
  4. 将目标文件、可执行文件和编辑器备份文件的名称放入忽略列表中。

Based on my experience with git, I would recommend the following:

  1. Create repository along with project.
  2. Commit as often as you can with detailed comments
  3. When you want to test a new idea - create a branch. If the idea is successful, merge your code to the master branch. If the idea is not successful, you can just discard the branch. Probably this is the most important idea.
  4. Put the names of object files, executables and editor backup files in the ignore list.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文