Chapter 6. Rewriting history and disaster recovery

This chapter covers

  • Viewing the history of all changes made to branches over time
  • Making a branch point to a previous commit
  • Changing the parent of commits to point to another
  • Forcing push-rewritten history to a remote repository
  • Rewriting the entire history of a branch
  • Avoiding losing your work

Technique 4 briefly discussed that Git is capable of rewriting the history of a repository. Because each repository contains the entire history, this ranges from undoing a single commit to rewriting data on every commit in the repository. I make use of rewriting history regularly to ensure that merged branches have a clean, readable history made up of small commits before merging. You can read ...

Get Git in Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.