Niccolo M.
Niccolo M.

Reputation: 3413

Creating a backwards git branch

I have the following branch:

c1--c2--c3--c4--c5--c6

I want to create a new branch which is the "reverse" of it. Like this:

c6'--c5'--c4'--c3'--c2'--c1'

Why do I need this?

I inherited a small project that had no history (it was not under revision control). I wanted to create a history for it. I did this by removing feature after feature after feaure. After each step I created a commit. In other words, I went backwards in time. Because it was easier.

Now I need to "reverse" the history.

Upvotes: 2

Views: 54

Answers (1)

isherwood
isherwood

Reputation: 61083

One possible approach:

  1. Create a temporary branch and make your un-changes on it, committing each time.
  2. Revert each commit on the temporary branch.
  3. Create a new branch from the simplest state of the temporary branch.
  4. Cherry-pick each revert commit from the temporary branch onto the final branch in the correct order.

Upvotes: 2

Related Questions