How to do a pull request when my branch and master have no related history?

This is easily doable by doing the following:

  1. Checkout branch_x to work on it:

    git checkout branch_x

  2. Reset soft to master so that branch_x is now at the same place than master in the git history but all your changes are now staged (reset --soft doesn't touch files in the working directory and even add the changes directly to the staging area):

    git reset --soft master

  3. Commit the files so that it will create one commit containing just the changes made in branch_x compared to master

    git commit

And now branch_x is one commit ahead of master and you can create your PR. You perhaps will have to push --force depending if you already pushed branch_x


I found this to work, do your normal flow from the branch_x that you want to push up.

git add .
git commit -m "message"
git pull origin master(or whatever branch) --allow-unrelated-histories
git push origin branch_x

you should now be able to compare and PR

Tags:

Git

Github