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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.