Git merge from same branch?

Viewed 176

I have a single branch in the form of:

 a --> b --> c
 ^           ^
 |           |
main        dev

I want to make another connection between a and c. A visual:

 ----> b --->
 |          |
 a -------> c
 ^          ^
 |          |
main       dev

How would I do this with git? Is it possible?

1 Answers

Assuming you want to keep the contents of c in the new revision:

git commit-tree -p main -p b -m "one comment" c^{tree}

That will give you a revision id as the result. Feel free to check it with git log or git checkout.... when you feel like that is what you want:

git branch -f dev the-id

And you are done

Related