Loren
Loren

Reputation: 14856

How do I edit a commit that is a common ancestor of multiple branches?

branch A
|
| branch B
| |
|/
|
commit X
|
|
...

How do I edit commit X to become X' such that both A and B have X' in their history? (All commits and branches are local.)

Upvotes: 0

Views: 211

Answers (1)

eftshift0
eftshift0

Reputation: 30204

You have to rewrite branches history (with all its implications):

git checkout x
# do changes
git add .
git commit --amend
# now we have X'... let's create a temp branch here
git branch temp
git rebase --onto temp x A # rebase branch A onto temp
git rebase --onto temp x B # rebase branch B onto temp

Now, you could delete temp

git branch -d temp

Upvotes: 4

Related Questions