Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Commit Daily or Commit when Feature is completed?

I want to know what will be more feasible (or convention to follow) if i Commit/Push my daily progress on a feature or i Commit/Push when a feature or a module is completed ?

like image 756
Arslan Ameer Avatar asked Nov 08 '18 17:11

Arslan Ameer


1 Answers

It depends on what you mean by "Commit" in this context. For many historical / non-git users, the notion of a "commit" was to commit changes back to the definitive central repository (from which all other users pull updates).

So, do you mean a git "commit" to your local repo, or a git "push" to the remote repo?

If it's a local repo "commit" then do that all the time. And do it at the end of the day if it's not frowned upon. that way you can keep track of changes.

A "push" to the remote repo (to the associated feature branch, of course) is a different beast.

Much of this depends on how you and your team organize your work / work day. Some teams require the checkin (commit / push) so that you don't lose your work. Some are fine with "just commit locally, and push when it works".

It also depends on your team's branching strategy. Much of the time you may be the only person working on a feature. That means you're the only one in a branch. If you check in non-working code then it MIGHT not be an issue.

If you have multiple committers to a branch, then your broken code will stop their work when it comes time for them to commit.

If you have a process where all branches are CI builds then that means bad builds up on the CI board. You may not want that.

I am a fan of both pushing working code AND not losing my work. Here is my approach

  • Do your work in small chunks (blah blah Agile blah - not talking about that). Fix one part of what you're working on. If that works "ok" (doesn't blow out a tire) then commit the changes. IF your team is good with it then PUSH this work to the branch in the remote repo.

  • coordinate with your team, or watch the CI build of your branch to ensure the integrated code passes tests. If it's all good then keep going. If not then go back and fix your work until your branch is Green.

like image 119
Paul Landolt Avatar answered Oct 11 '22 15:10

Paul Landolt