如何使用不同类别的不同注释检入代码?

时间:2021-05-29 07:32:05

What do you think is the best practice for checking in code from multiple files that implement multiple changes, but are ready to go in at one time?

您认为从多个文件中检入代码来实现多项更改但是准备好一次进入的最佳做法是什么?

Do you check them all in at once, keeping the checking reasonably atomic, and put the changes in one long comment?

你是否一次检查它们,保持合理的原子检查,并将更改放在一个长评论中?

Do you check in the files in groups so the right comment is associated with the right file?

您是否在组中签入文件,以便正确的评论与正确的文件相关联?

Do you have tools which let you check in at once with different comments on different files?

您是否有工具可以让您立即通过不同文件的不同评论办理登机手续?

5 个解决方案

#1


Check all at once. If you check in groups you make break the build.

一次检查所有。如果您签入组,则可以打破构建。

But it is better to check in as you get the change done.

但是,当您完成更改时,最好办理登机手续。

#2


I use Git, which allows you to easily resolve the tangled working copy problem. I can work away without worrying about which changes are related to what, then after I've done a few things step back and commit each logical change individually, with its own commit message.

我使用Git,它可以让你轻松解决纠结的工作副本问题。我可以不用担心哪些更改与什么有关,然后在我做了一些事情后退一步并单独提交每个逻辑更改,并使用自己的提交消息。

This method is great for keeping small, logical changes together. If I look back at the history of a file with git annotate, I can easily see why each change was made without having one commit covering a whole bunch of unrelated changes. Furthermore, as somebody else mentioned, having smaller commits makes it easier to roll back a previous modification if you change your mind later.

此方法非常适合将小的逻辑更改保持在一起。如果我回顾一下使用git annotate的文件的历史记录,我可以很容易地看到为什么每次更改都是在没有一个提交覆盖了大量不相关的更改的情况下进行的。此外,正如其他人所提到的,如果您稍后改变主意,那么提交较小的提交会使回滚先前的修改变得更容易。

#3


So long as their aren't dependencies among multiple changes, keep your check in's small. Check in the smallest collection of changes that won't break the build or introduce other problems.

只要它们不是多个变化之间的依赖关系,请保持您的签入很小。检查最小的更改集合,这些更改不会破坏构建或引入其他问题。

For bugs or small change request, usually one check in per bug (or change) tends to work best. This allows you to easily identify which file (or files) were updated to address a particular issue. this is not only helpful in rolling back changes but also in determinie what changes were made to fix an issue should a similar problem arise in the future.

对于错误或小变更请求,通常每个错误(或更改)的一个签入往往效果最好。这使您可以轻松识别哪些文件(或多个文件)已更新以解决特定问题。这不仅有助于回滚变更,还有助于确定在未来出现类似问题时如何修复问题。

For major changes, if they can be broken down into smaller units of work to be checked in, do so. A - if you do need to roll back something because of a minor mistake, having to rollback all of the changes is just plain depressing. B - hard drives crash - if you are working on something for an extended period of time, the more changes you implement and the longer you work without checking in, the greater risk you are putting your work and your organization in.

对于重大更改,如果可以将它们分解为要检入的较小工作单元,请执行此操作。答:如果你确实因为一个小错误而需要回滚一些东西,那么必须回滚所有的变化只是令人沮丧。 B - 硬盘崩溃 - 如果您长时间处理某些事情,您实施的更改越多,无需办理登机手续的时间越长,您将工作和组织投入的风险就越大。

#4


I try to keep each check-in related to a specific ticket number, project, etc.

我尝试将每张登记入住与特定的票号,项目等相关。

#5


Keeping checkins as small as possible is good practice for a number of reasons, especially if you want to roll back anything. For this reason, try and check in code in the smallest "meaningful" increments possible (as long as everything still compiles after each checkin).

保持签到尽可能小是好的做法有很多原因,特别是如果你想要回滚任何东西。出于这个原因,尝试以最小的“有意义”增量检查代码(只要在每次检查后仍然编译所有内容)。

#1


Check all at once. If you check in groups you make break the build.

一次检查所有。如果您签入组,则可以打破构建。

But it is better to check in as you get the change done.

但是,当您完成更改时,最好办理登机手续。

#2


I use Git, which allows you to easily resolve the tangled working copy problem. I can work away without worrying about which changes are related to what, then after I've done a few things step back and commit each logical change individually, with its own commit message.

我使用Git,它可以让你轻松解决纠结的工作副本问题。我可以不用担心哪些更改与什么有关,然后在我做了一些事情后退一步并单独提交每个逻辑更改,并使用自己的提交消息。

This method is great for keeping small, logical changes together. If I look back at the history of a file with git annotate, I can easily see why each change was made without having one commit covering a whole bunch of unrelated changes. Furthermore, as somebody else mentioned, having smaller commits makes it easier to roll back a previous modification if you change your mind later.

此方法非常适合将小的逻辑更改保持在一起。如果我回顾一下使用git annotate的文件的历史记录,我可以很容易地看到为什么每次更改都是在没有一个提交覆盖了大量不相关的更改的情况下进行的。此外,正如其他人所提到的,如果您稍后改变主意,那么提交较小的提交会使回滚先前的修改变得更容易。

#3


So long as their aren't dependencies among multiple changes, keep your check in's small. Check in the smallest collection of changes that won't break the build or introduce other problems.

只要它们不是多个变化之间的依赖关系,请保持您的签入很小。检查最小的更改集合,这些更改不会破坏构建或引入其他问题。

For bugs or small change request, usually one check in per bug (or change) tends to work best. This allows you to easily identify which file (or files) were updated to address a particular issue. this is not only helpful in rolling back changes but also in determinie what changes were made to fix an issue should a similar problem arise in the future.

对于错误或小变更请求,通常每个错误(或更改)的一个签入往往效果最好。这使您可以轻松识别哪些文件(或多个文件)已更新以解决特定问题。这不仅有助于回滚变更,还有助于确定在未来出现类似问题时如何修复问题。

For major changes, if they can be broken down into smaller units of work to be checked in, do so. A - if you do need to roll back something because of a minor mistake, having to rollback all of the changes is just plain depressing. B - hard drives crash - if you are working on something for an extended period of time, the more changes you implement and the longer you work without checking in, the greater risk you are putting your work and your organization in.

对于重大更改,如果可以将它们分解为要检入的较小工作单元,请执行此操作。答:如果你确实因为一个小错误而需要回滚一些东西,那么必须回滚所有的变化只是令人沮丧。 B - 硬盘崩溃 - 如果您长时间处理某些事情,您实施的更改越多,无需办理登机手续的时间越长,您将工作和组织投入的风险就越大。

#4


I try to keep each check-in related to a specific ticket number, project, etc.

我尝试将每张登记入住与特定的票号,项目等相关。

#5


Keeping checkins as small as possible is good practice for a number of reasons, especially if you want to roll back anything. For this reason, try and check in code in the smallest "meaningful" increments possible (as long as everything still compiles after each checkin).

保持签到尽可能小是好的做法有很多原因,特别是如果你想要回滚任何东西。出于这个原因,尝试以最小的“有意义”增量检查代码(只要在每次检查后仍然编译所有内容)。