Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Github fork to existing repository

Tags:

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?

like image 351
Mark Nichols Avatar asked Aug 26 '11 20:08

Mark Nichols


People also ask

Can I fork into an existing repo?

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.

How do I sync my fork with the original git repository?

GitHub has now introduced a feature to sync a fork with the click of a button. Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.


2 Answers

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."

like image 85
Karl Bielefeldt Avatar answered Oct 04 '22 01:10

Karl Bielefeldt


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).

like image 28
Barend Avatar answered Oct 04 '22 02:10

Barend