Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How often to commit changes to source control? [closed]

People also ask

How often should you commit changes to git?

At least a couple of times every hour, with 5 being quite a bit. Show activity on this post. You shouldn't commit based on a time basis, but on a feature basis. Whenever you add a new feature that's worth committing, commit.

How often should I push my commits?

Typically pushing and pulling a few times a day is sufficient. Like @earlonrails said, more frequent pushes means less likelihood of conflicting changes but typically it isn't that big a deal. Think of it this way, by committing to your local repository you are basically saying "I trust this code. It is complete.

When should I make the first commit to source control?

You should do your first commit wherever it feels logical to do it, that means, wherever you reach a point that the work you did is logical enough to justify one, and only one, commit; just as you do in your normal workflow.

When should you make a commit?

Commit early, commit often If you are working on a feature branch that could take some time to finish, it helps you keep your code updated with the latest changes so that you avoid conflicts. Also, Git only takes full responsibility for your data when you commit.


Anytime I complete a "full thought" of code that compiles and runs I check-in. This usually ends up being anywhere between 15-60 minutes. Sometimes it could be longer, but I always try to checkin if I have a lot of code changes that I wouldn't want to rewrite in case of failure. I also usually make sure my code compiles and I check-in at the end of the work day before I go home.

I wouldn't worry about making "too many" commits/check-ins. It really sucks when you have to rewrite something, and it's nice to be able to rollback in small increments just in case.


When you say you are concerned that your "commits affect the whole repository" --- are you referring to the fact that the whole repository's revision number increases? I don't know how many bits Subversion uses to store it, but I'm pretty sure you're not going to run out of revision numbers! Many commits are not a problem. You can commit ten times as often as the guy next door and you won't increase your carbon footprint at all.

A single function or method should be named for what it does, and if the name is too long, it is doing too much. I try to apply the same rule to check-ins: the check-in comment should describe exactly what the change accomplishes, and if the comment is too long, I'm probably changing too much at once.


I like this small article from Jeff Atwood: Check In Early, Check In Often


I personally commit every logical group of code that is finished/stable/compiles and try not to leave the day without committing what I did that day.


If you are making major changes and are concerned about affecting others working on the code, you can create a new branch, and then merge back into the trunk after your changes are complete.