Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

I have a branch, "branch_x", that is part of the same repository as master. However, I foolishly started developing on branch_x without checking out from master. Therefore there is no common ancestor between master and branch_x, and when I tried doing a pull request to master, I simply got: There isn’t anything to compare. master and branch_x are entirely different commit histories.

Because of that fault, I made a fork of that repository. I am trying to merge the commits of branch_x into the master branch of the fork, and then I will try to request a pull between original repository and the fork (because now they have some history in common). However, I have no idea of how to actually merge branch_x from the original repo, to the master branch of the fork.

This post is similar, but I don't think that "git rebase -onto" will help much: There isn't anything to compare. Nothing to compare, branches are entirely different commit histories

like image 438
django_moose Avatar asked Aug 21 '18 19:08

django_moose


1 Answers

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

like image 111
PhilCowan Avatar answered Oct 20 '22 15:10

PhilCowan