Add Github fork to existing repository

15,930

Solution 1

Although people tend to think of their repo on Github as the "official" one, remember that's a social distinction and not a technical one. From git's point of view every repo is on equal terms. That means as long as you have pulled every commit into your local repo, you can safely delete the one on Github. Then just fork the Octopress project on github, set it up as a remote on your local repo, and push. Git doesn't care which repo you originally got any given commit from. It "just works."

Solution 2

I'm unaware of any way to turn your blank github copy into a github fork after the fact, so

If there isn't a way, can I safely delete my Github instance of Octopress, fork the original on Github, and then add a new remote from my local repository to the newly forked Octopress?

is the way to go. Delete your own github repository, hit the fork button on the octoprocess repository and clone your fork to your local machine.

If you've already made any changes that you with to keep, I'd say that using git format-patch to store them as a series of patch files and git apply-patch to apply those on a clone of your new repository is probably easier than using the old one as a remote (on your local machine).

Share:
15,930

Related videos on Youtube

Mark Nichols
Author by

Mark Nichols

Software nerd, cellist, husband, and all-around good guy.

Updated on June 28, 2022

Comments

  • Mark Nichols
    Mark Nichols almost 2 years

    I setup an Octopress project following the given instructions (http://octopress.org/docs/setup/) which have you create a Github repository, and create a local repository on your machine. On your local machine you add a remote to the original Octopress repository and then issue a "git pull" command. Then you add a remote to your Github repository so you can push your changes to your repository.

    All of this works as far as it goes, but it doesn't create a fork of the original project, meaning there's no obvious (to a newbie) way to issue a pull request to the original Octopress repository.

    Is there a way for me to add a fork of the original Octopress repository to my instance of that repository on Github?

    If there isn't a way, can I safely delete my Github instance of Octopress, fork the original on Github, and then add a new remote from my local repository to the newly forked Octopress?

  • Mark Nichols
    Mark Nichols almost 13 years
    Here are the steps I followed: (1) I deleted the Github repository, (2) I forked Octopress, (3) I removed the remote that tied my local repository to the now deleted one, (4) I added a new remote ("origin") to the newly forked Octopress repository, (5) I did a git pull origin master to get past the "! [rejected] master -> master (non-fast-forward)" error, (6) I cleaned up the few merge conflicts (caused by updates to Octopress that I hadn't pulled down yet), (7) regenerated my site to verify it was all working properly, and finally, (8) pushed from my local repository back to Github.