Created
October 12, 2016 13:34
-
-
Save flexbox/f13fcf1218f95f7215c5c6b34ab7046a to your computer and use it in GitHub Desktop.
How to fork your own repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A git fork is really just a git clone plus a change of ownership. What this does is a git clone plus a change of name, maintaining an upstream link to the source repo so you can integrate changes. | |
Here's a recipe for duplicating a repo: | |
git clone username/old_repo new_repo | |
cd new_repo | |
git remote rename origin upstream | |
git create username/new_repo | |
git push -u origin master | |
This uses the "hub" addon for command-line git integration with github; find it at https://hub.github.com. If you prefer not to use it, the following recipe is a bit more work: | |
git clone [email protected]:USERNAME/OLD_REPO.git NEW_REPO | |
cd NEW_REPO | |
git remote rename origin upstream | |
[create empty repo on github] | |
git set remote origin [email protected]:USERNAME/NEW_REPO.git | |
git push -u origin master | |
By default, any git push will go to the repository you most recently pulled from, which means the repository you cloned from. For those of us who always say 'git pull origin master' this isn't a problem; for those of us who rely on defaults, this setting will set the default for git push to do the right thing: | |
git config --global remote.pushdefault origin | |
If you want to integrate changes from the original repository: git pull upstream | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment