NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.