Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why keep git history clean? [closed]

Tags:

git

I had a talk with teammate about git. I tried to convince him that he should use amend, rebase -i and use meaningful commit messages. He just asked "why" and well... That's a good question. I tried to use argument like clean history, easier to read and find bugs, and well it looks nice. He just said that who the hell reads git commits or check out tree, everybody just commit — push and when time comes merge it. Why bother?

To be honest I had no idea what to say. The worst part is that rest of the team thinks similar. Can somebody please help me, how can I convince them to do a little more work just to keep git clean?

The worst part is I am new in the team and a lot younger than others, so I can't just use more experienced developer card.

EDIT

Since there is a misunderstanding about what I meant by rebase: I try to convince team to use rebase -i when you are working on local changes, on local branch which is not pushed. Just to clean up if you didn't amend in time.

like image 768
Noskol Avatar asked Jul 15 '19 06:07

Noskol


2 Answers

The question boils down to whether you need a history in your VCS repositories or not. You do need it in cases when:

  • You need to find the task in your tracker. The task may contain information about why the change was introduced.
  • Need to read commit message that explains the change
  • Find the person who introduced the change in order to ask him questions about it. Maybe break couple of fingers.
  • Figure out when the bug was introduced. Often that's just curiosity, but it may uncover interesting trends.
  • Revert the change if malfunction was discovered late
  • Catch up with the changes made by your colleagues yesterday. Or while you were on vacation.

So if the history is easy to inspect, these goals are easily achievable.

like image 161
Stanislav Bashkyrtsev Avatar answered Oct 21 '22 08:10

Stanislav Bashkyrtsev


Nowadays Git is not used in a vacuum, and I think your team is right.

There is often a bug tracker, a code review tool (that uses pull requests) and a CI system that build the code and runs the tests in cloud. These are integrated together and systems are in place to ensure that no broken code is merged to the main branch and everything is properly reviewed and approved before the merge.

And primarily these tools are used to keep track of the work and not the Git history.

If there is a bug, then VSCode's Git Lens extension shows immediately who changed the problematic line the last time. So we can ask him. But even if we are not sure we can always go to the team chat and mention "hey why did we wrote this that way?". We don't assign blame.

In the last 5 years since we moved to Git from Perforce I never had to look back or bisect the git history ever.

like image 29
Calmarius Avatar answered Oct 21 '22 08:10

Calmarius