Skip to content

Instantly share code, notes, and snippets.

@joncode
Created May 29, 2013 18:37
Show Gist options
  • Save joncode/5672659 to your computer and use it in GitHub Desktop.
Save joncode/5672659 to your computer and use it in GitHub Desktop.

Let’s assume we have an existing project called ‘foo’ and we want to create a fork called ‘bar’.

First, create a new project on GitHub called ‘bar’.

Next, clone foo using the name ‘bar’:

$ git clone [email protected]:YOURNAME/foo.git bar
$ cd bar

Next, edit your Git config file and replace the origin URL with your new URL:

$ vim .git/config

Add your original repo as an upstream source:

$ git remote add upstream [email protected]:YOURNAME/foo.git

Finally, push your new repository up to GitHub:

$ git push -u origin master

Now you can push/pull from your new repo (bar) as expected. You should also be able to merge upstream changes using the following command:

$ git fetch upstream
$ git merge upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment