O'Reilly logo

Pragmatic Version Control Using Git by Travis Swicegood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rewriting History

Revisionist historians view history as a living thing—something that needs to be reevaluated from time to time to make sure the assumptions that were made in the past still apply.

Looking over your code as part of a formal code review is a great way to make sure the assumptions you made last week or last month still apply. Git lets you take this a step further, though, by allowing you to not only review the history of your code but to rewrite it.

There are a few instances where this is useful:

  • Reorder the history so it makes more sense: This is the hardest to quantify, but you’ll know it when you see it. One commit, or maybe more, seems out of place and logically fits in a different order.

  • Squash several commits into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required