-1

I have a personal project GitHub repository that used the squash and merge option for pull requests.

How do I rewrite the Git history so that the pull requests used the merge commit option instead of squash and merge?

2 Answers 2

3

Squash merges are destructive operations and there is no way to reverse them.

It is a really, really bad practice and you should stop using them.


If you are lucky you might find traces of the original branch that was used to create the pull request, so that you could resurrect those commits and create a new branch on the last commit. With that you might change your main branch by discarding the squash commits and replace with real merges using reset, rebase and/or interactive rebase.

To hunt locally in your repository you can use git reflog or gitk --reflog to find "unconnected" commits that has not been discarded yet.

On the remote side I think github has some history references to commits in the pull requests that you might be able fetch.

This task will not be trivial but it will be a great learning experience for you. NB, start by making a copy of the whole repository directory so you have a backup to fall back to or to start over again.

Sign up to request clarification or add additional context in comments.

Comments

0

I solved this by doing git reset --hard to before my first PR merge.

Then, I cherry-picked the individual commits of each PR and did git push.

This solution doesn't exactly use merge commits like GitHub, but I found out I actually like a linear history more.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.