Setting git parent pointer to a different parent

Viewed 112702

If I have a commit in the past that points to one parent, but I want to change the parent that it points to, how would I go about doing that?

5 Answers

Definitely @Jakub's answer helped me some hours ago when I was trying the exact same thing as the OP.
However, git replace --graft is now the easier solution regarding grafts. Also, a major problem with that solution was that filter-branch made me loose every branch that wasn't merged into the HEAD's branch. Then, git filter-repo did the job perfectly and flawlessly.

$ git replace --graft <commit> <new parent commit>
$ git filter-repo --force

I've made a question like this some time ago, so the complete answer can be found here.


Fore more info: checkout the section "Re-grafting history" in the docs

Related