Search code examples
gitgithubbranchgithub-pagesgit-fork

Replace master branch with new forked branch


I forked a repo that I own to make some changes to the gh-pages branch. I ended up creating a new one from scratch so now it does not share commit history with the original.

I now want to merge this new gh-pages branch back to the original repo, replacing the original gh-pages branch.

When I try to compare and create a pull request, I get this error on github.

Forked_Repo:gh-pages and Original_Repo:gh-pages are entirely different commit histories.

How should I go about replacing the gh-pages on my original repo with the new version on the fork?


Solution

  • You could delete the branch gh-pages on original repo and then push the new gh-pages to it.

    In the folk repo, you set original repo as a remote:

    git remote add upstream <original-repo-url>
    

    And then push gh-pages to upstream:

    git push -f upstream gh-pages
    

    Edited: add detail command to push branch from fork to origin