TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Best practices for teams using Git

2 pointsby jermieralmost 5 years ago

1 comment

gregmacalmost 5 years ago
This misses using `git pull --rebase` [1] (or even better: `git config --global pull.rebase true`), which greatly simplifies things working with others, and avoids tons of extra merge commits. It also doesn&#x27;t have the downside of rewriting remote history like a straight `git rebase` can.<p>&gt; With &quot;pure merge&quot; strategies (without rebasing regularly, as suggested above), the history in the master branch will be interspersed with the commits from all the features being developed concurrently. Such a mixed-up history is harder to review. The exact commit times are usually not that important. It&#x27;s better to have a history that&#x27;s easier to review.<p>This seems to be a common sentiment. I don&#x27;t get it, but maybe someone can explain what I&#x27;m missing?<p>I am a strong advocate of using pull requests to merge to master, and merging them using `--no-ff`. Each PR has a merge commit on master.<p>If you&#x27;ve ever worked on a feature branch (and have a local copy of it in your repository) it&#x27;s simple to see when it&#x27;s safe to delete, because you can literally trace it making its way into master (or a hotfix branch, if relevant). When you do squash or rebase merges, this feature goes away.<p>With any even moderately-sized feature (tens or more of commits, eg, a few days&#x27; work or more), the individual commits can sometimes contain value later. Doing a git blame months later, it&#x27;s occasionally useful to diagnose why something is done a certain way. Squash merges lose this detail.<p>What do you get for all these tradeoffs that affect daily work -- a &quot;clean history&quot; on master? Wtf?<p>I&#x27;d rather look a list of tickets, merged PRs, or the release notes to see what&#x27;s changed. If I <i>really</i> want to look at it in git I can do `git log --merges --oneline`.<p>The only time I ever scroll back through the tree looking at the actual graph is when I&#x27;m trying to figure out why some branch did or did not get merged somewhere, and this feature is compromised with rebase merges, and doesn&#x27;t even exist with squash merges!<p>Squash merge (and to a lesser extent, rebase merge) make a bunch of useful things harder or impossible, and the only benefit I see is superficial and one I <i>never</i> use. Am I alone in this? I feel like I&#x27;m taking crazy pills every time I see advocacy for a squash merge strategy.<p>(I&#x27;ll leave fast-forward merge out: That keeps the &quot;messy&quot; history that squash advocates apparently don&#x27;t like, but also makes the lineage of a feature branch confusing as a ff merge looks like work was just done on master directly. My probably naive assumption is that no one ever uses ff merge on master.)<p>[1] <a href="https:&#x2F;&#x2F;coderwall.com&#x2F;p&#x2F;7aymfa&#x2F;please-oh-please-use-git-pull-rebase" rel="nofollow">https:&#x2F;&#x2F;coderwall.com&#x2F;p&#x2F;7aymfa&#x2F;please-oh-please-use-git-pull...</a>