Git 工作流程:保留还是保留旧代码?
Git workflow: leave or keep an old code?
我们是一个由数据科学家组成的小团队,在 Git 存储库中维护一些业务流程。
我们有很多无效和未使用的代码,例如 process.R
、process_1_1_0.R
和 process2.R
(显然,只有一个被使用)。
这个想法一直是保留一些旧代码 'in case something happens'。
由于所有更改都保存在 Git 中,所以我建议最终删除所有未使用的文件。我的想法只被部分接受,建议将所有内容放入 backup
子目录,原因是它是 'quicker and easier to recover an old working version this way'.
但这有意义吗?
有人可以评论 and/or 参考一些适用的 Git 工作流程吗?
谢谢。
删除它。由于它处于版本控制之下,您可以随时恢复它。保留无用的代码只是为您和您的团队支付的维护成本。
参见this or this question or this blog post。
编辑:人们经常谈论注释掉的代码,比如 here or here:
Don’t comment out code; remove it. The problem here is that it’s very
tempting never to remove old code, perhaps out of fear to lose it.
Other developers may not understand why code was commented out, and
leave it there. [...]
但是所有关于这方面的内容也适用于包含旧代码的文件,就像您的情况一样。在我看来,拥有一个包含未使用代码的文件更糟糕,因为它比您不时偶然发现的注释掉的代码块更容易忘记。
我们是一个由数据科学家组成的小团队,在 Git 存储库中维护一些业务流程。
我们有很多无效和未使用的代码,例如 process.R
、process_1_1_0.R
和 process2.R
(显然,只有一个被使用)。
这个想法一直是保留一些旧代码 'in case something happens'。
由于所有更改都保存在 Git 中,所以我建议最终删除所有未使用的文件。我的想法只被部分接受,建议将所有内容放入 backup
子目录,原因是它是 'quicker and easier to recover an old working version this way'.
但这有意义吗? 有人可以评论 and/or 参考一些适用的 Git 工作流程吗?
谢谢。
删除它。由于它处于版本控制之下,您可以随时恢复它。保留无用的代码只是为您和您的团队支付的维护成本。
参见this or this question or this blog post。
编辑:人们经常谈论注释掉的代码,比如 here or here:
Don’t comment out code; remove it. The problem here is that it’s very tempting never to remove old code, perhaps out of fear to lose it. Other developers may not understand why code was commented out, and leave it there. [...]
但是所有关于这方面的内容也适用于包含旧代码的文件,就像您的情况一样。在我看来,拥有一个包含未使用代码的文件更糟糕,因为它比您不时偶然发现的注释掉的代码块更容易忘记。