git提交频率 [英] git commit frequency

查看:111
本文介绍了git提交频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我从svn切换到git,我开始在每次重新编译时都做出更多的提交,并且我的测试通过了我的工作。最后,我最终通过函数提交了函数。



我还跟踪一些使用像emacs,wordpress等git的项目。我发现它们并没有经常提交。所以我很想知道你们如何提交?

解决方案

Git项目本身的准则(和Linux项目AFAIK)是每个逻辑上独立的变更集的一次提交。



这有点含糊不清,但如果你不断地在一个项目上工作,你可能不想每隔几天就提交一次,而你可能不希望在每次函数更改后提交 - 如果您已经在几个不同的文件中编辑了几个函数,如果可以提供所有相关的功能并提供一个有用的提交消息,那么您希望提交所有相关的功能。所有在每次提交中修改的代码都应该是相关的,但它可以(也可能应该)跨越多个文件。



你可能想要记住的是在代码评论。如果有人试图确定他们是否应该合并您的工作,那么如果您的每个提交都被逻辑地包含并彼此分开,那么他们处理正在引入的工作就容易得多。这样可以让你(或其他人)有效地选择工作 - 如果你有三个提交,每个提交一个函数,但它们都以某种方式耦合 - 你不能在没有其他两个的情况下应用一个,而不会破坏代码库 - 那么他们可能应该被压扁到一次提交。


Since i switched to git from svn i started make more commits every time i recompile and my tests pass i commit my work. In the end i end up committing function by function.

I also track some other projects using git like emacs,wordpress etc. I see that they do not commit that often. So i am wondering how ofthen do you commit?

解决方案

The guideline for the Git project itself (and the Linux project, AFAIK) is one commit per "logically separate changeset".

This is a little ambiguous, but you probably don't want to commit every few days if you're working on a project constantly, and you probably don't want to commit after every function change - if you've edited several functions in several different files, you want to commit all of the related functionality together if you can and provide a useful commit message with it. All of the code modified in each commit should be related, but it can (and probably should) certainly be across several files.

What you probably want to keep in mind is in code reviews. If someone is trying to decide if they should merge your work in, it's much easier for them to process the work being introduced if you have each commit logically contained and separate from each other. That lets you (or others) cherry pick work effectively - if you have three commits with one function modified in each but they're all coupled somehow - you can't apply one without the other two without breaking the codebase - then they should probably be squashed down to one commit.

这篇关于git提交频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆