1

I'm playing with GitHub actions and testing a commit linter on a PR (from a dummy branch called meh to master), which I managed to make it work, except that I needed to change my previous commit messages (which were already pushed at that point) in order to match the commit linter regex (which uses conventional commit).

So I went with a git rebase -i --root and reword-ed every commit since the very beginning and then I pushed the commits to my branch meh, except that when I did that the PR closed automatically, I can't reopen or create a new one (from the same branch meh to master) cause according to GitHub:

The meh branch has no history in common with master.

How can I re-open my PR?

8
  • Not too surprised. I cloned your repo, and (on master) tried to do a git merge meh and it told me fatal: refusing to merge unrelated histories. If a merge would fail in this way, then a pull request can't make sense. Commented Jun 19, 2020 at 23:57
  • @alaniwi Yea and that's the reason why my question is how to fix that? Commented Jun 20, 2020 at 0:00
  • It seems that there is a non-default option called --allow-unrelated-histories which will allow the merge, so maybe you do that locally, commit to a new branch, push that new branch, and then do a PR from your new branch. Commented Jun 20, 2020 at 0:02
  • @alaniwi thanks will try this out, fingers crossed =| Commented Jun 20, 2020 at 0:03
  • 1
    @alaniwi what worked for me to re-open the PR: git pull origin master --allow-unrelated-histories. Tbs, it kinda messed up the commit linter in fetching the commits. See: github.com/wagoid/commitlint-github-action/issues/… Commented Jun 20, 2020 at 18:42

1 Answer 1

4

Just like what @alaniwi said, this could be solved with what is described here:

Try the following command:

git pull origin master --allow-unrelated-histories

This should solve your problem.

That being said, you can also mess up the SHA1 of your commits at some point, if you have to git push --force ..., so yea it would work out to re-open the PR, but your CI might scream a little bit.

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

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.