Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git fake merge (marking a commit as merged without a real merge) [duplicate]

Assume I have the following history in my repository:

     E--F
    /
A--B--C---D

And I want to modify it to be this:

     E--F
    /    \
A--B--C---D

I don't want to modify file content of revisions, I just want to "draw a merge arrow". How can I do this?

I tried to do this by the following commands:

git checkout D
git merge F -s ours --no-ff --no-commit
git commit --amend

But I got the following error message:

fatal: You are in the middle of a merge -- cannot amend.

I want to leave the commit information unchanged (author, date, message). The only thing I want to change is to add pseudo merge-info to the commit.

like image 536
anton_rh Avatar asked Apr 16 '18 13:04

anton_rh


1 Answers

This worked for me:

git checkout D~1
git merge F -s ours --no-ff --no-commit
git cherry-pick D -n
git commit -C D
git branch -f D
git checkout D
like image 147
anton_rh Avatar answered Oct 18 '22 22:10

anton_rh