David S.
David S.

Reputation: 11168

Git: Add commits to history that were 2 commits earlier

I have a git repo which looks like this:

A -- B --C -- HEAD

Now I want to go back to A, make some change then rebase B and C on top of that. So I want my updated history looks like:

A -- A1 -- A2 -- B -- C

None of these changes has been published. I kinda think git checkout A could help. But I could not figure out the workflow. Any suggestions?

Upvotes: 0

Views: 28

Answers (1)

Ateş Göral
Ateş Göral

Reputation: 140050

There could be more than one way to do this. A workflow that I would find clear would be:

  1. git checkout A
  2. git checkout -b a-edits
  3. do your commits
  4. git checkout master
  5. git rebase a-edits

Upvotes: 2

Related Questions