Is squashing commits a good idea?

Normally, if you’re merging a pull request from a feature branch with a messy commit history, you should overwrite your commits. There are exceptions, but in most cases overriding results in a cleaner Git history that’s easier for the team to read.

Why is commit overwriting bad?

It breaks down some of git’s most powerful features for learning, refactoring, and debugging. If we write good commit messages, overwriting a branch deletes that information, or if we list all commit messages in the overridden commit, it separates those messages from the code they describe.

What is the benefit of overwriting commits?

Commit squashing has the benefit of keeping your Git history neat and digestible than the alternative created by merge commits. While merge commits keep commits like “Oops, you missed a spot” and “Maybe fix this test?” [Round 2]”, the overwrite preserves the changes but omits the individual commits from the history.

Does overwriting commits save space?

In general, I don’t think it’s worth trying to do this for individual commits. Overwrite a bunch of commits when the result is a more sensitive history, don’t just do it to save disk space. It might save a little, but not enough to be worth the loss of a useful history.

Are merge commits bad?

Explicit merge commits are usually perfectly fine. You usually apply this kind of merge commit even by saying git merge noff .

Is overwriting commits bad?

So while there is nothing inherently wrong with overriding commits, and tactical overriding is a valuable thing, it’s important to remember that overriding is an inherently destructive act that removes development-stopping issues. 06

Is overriding commits a good idea?

Normally, if you’re merging a pull request from a feature branch with a messy commit history, you should overwrite your commits. There are exceptions, but in most cases overriding results in a cleaner Git history that’s easier for the team to read. 30

Does overwriting commits save space?

In general, I don’t think it’s worth trying to do this for individual commits. Overwrite a bunch of commits when the result is a more sensitive history, don’t just do it to save disk space. It might save a little, but not enough to be worth the loss of a useful history. 27

Are overwritten commits lost?

Even if a commit is overwritten, it can still be recovered since the data resides in the commit history. Once you know the SHA of the blob to recover, use: $ git catfile p > recovery_file. 03

Are merge commits good?

Some people keep a merge commit, even for fast forward, because it records very well when a branch has completed. These people prefer a complete and accurate story to a clean story. Some people avoid merge commits even when rebasing their branches because it makes the history easier to read. 22

What’s the point of merge commits?

This introduction of a merge commit allows you to write a summary of the changes in the branch you are merging and allows people reading history in the future to choose whether to view the merge as a single commit or – as you wish – want to dive into commits that compromise the merged functionality. 23

What happens to commits after the merge?

So instead of merging, run the following on branchb first, git rebase master . This will create new commits that are copies of old commits, i.e. H. same changeset, author information and messages, but new committer information and change history. 9

Why is relining bad?

Relining can be dangerous! Rewriting shared branch history is subject to teamwork breaking. This can be mitigated by rebasing/squashing a copy of the feature branch, but rebasing implies that skill and caution must be used.

Exit mobile version