DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Developer Git Commit Hygiene
  • Understanding Git
  • The Art of the Bug Fix: Boosting Software Quality Through Effective Git Commits
  • Five Software Development Trends

Trending

  • Beyond Bytecode: Exploring the Relationship Between JVM, JIT, and Performance
  • OTel Me Why: The Case for OpenTelemetry Beyond the Shine
  • DevOps in the Cloud - How to Streamline Your CI/CD Pipeline for Multinational Teams
  • Master SQL Performance Optimization: Step-by-Step Techniques With Case Studies
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Git: To Squash or Not to Squash?

Git: To Squash or Not to Squash?

Take a quick look at the benefits and downsides to squashing all the commits on a given feature branch to just one commit.

By 
Steven Schwenke user avatar
Steven Schwenke
·
Sep. 04, 17 · Opinion
Likes (5)
Comment
Save
Tweet
Share
25.5K Views

Join the DZone community and get the full member experience.

Join For Free

Until recently, I told my team to squash all of their commits on a given feature branch to just one commit. Every feature branch consisted of just this one commit and could be integrated into develop so that develop reads just like a sequence of features. After further consideration, I changed that. Here are reasons for both approaches:

Pro-Squash

  1. Clean timeline: Development of features is clearly visible because every commit is a feature.
  2. Commits representing work in progress (WIP) broke builds on CI-server.
  3. WIP-commits prevented "jumping a month into the past" for debugging and exploratory purposes because they are potentially broken (compile errors, failing tests).

Anti-Squash

  1. If feature branches are merged, a merge commit is created that represents the development of a feature.
  2. Tools like Git Bisect are much more powerful when dealing with small commits.
  3. In IDEs like IntelliJ IDEA, feature branches in the Git history can be collapsed to provide a better overview.
  4. Small tasks are better visible. For example, small bugfixes tended to be fixed in bigger feature branches, just to be never found again. "Yeah, this got fixed somewhere, but I don't know where"-syndrome.
  5. Every commit causes the CI-server to build. The more (pushed) commits, the more builds, the faster feedback if something went wrong.

To get the most out of the new strategy, each commit must

  1. Compile and run green (all tests), AND
  2. Have a good commit-message (see 7 rules of good commit messages).

Furthermore, really small commits may be merged with a fast-forward-merge/rebased onto develop.

Also, commits that represent a quick-WIP-save have to be edited in retrospect and provided with a good commit message. This is the last remaining situation in which a squash is allowed.

Git Commit (data management)

Published at DZone with permission of Steven Schwenke. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Developer Git Commit Hygiene
  • Understanding Git
  • The Art of the Bug Fix: Boosting Software Quality Through Effective Git Commits
  • Five Software Development Trends

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: