Forked from jpierson/switch-local-git-repo-to-fork.md
Last active
July 18, 2025 17:49
Revisions
-
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git branch --set-upstream-to origin/master master ``` 6. Push to your fork via your "origin" remote (the word `origin` should be able to be omitted (ie: just write `git push`) if you did Step 4). ```bash git push origin -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git branch --set-upstream-to origin/master master ``` 6. Push to your fork via your "origin" remote (the word `origin` should be able to be omitted [ie: just write `git push`] if you did Step 4). ```bash git push origin -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,14 @@ If you are like me you find yourself cloning a repo, making some proposed change To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as **origin** and the original forked repository as **upstream** so that you can use these keywords in other git commands. 1. Clone some repo (you've probably already done this step). ```bash git clone git@github...some-repo.git ``` 2. Manually [fork their repo](https://guides.github.com/activities/forking/) via the Github website directly. 3. In your local system, rename your **origin** remote to **upstream**. ```bash git remote rename origin upstream @@ -21,7 +21,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git remote add origin git@github...my-fork ``` 4. Fetch from new origin. ```bash git fetch origin @@ -35,7 +35,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git branch --set-upstream-to origin/master master ``` 6. Push to your fork via your "origin" remote (`origin` should be able to be omitted if you did Step 4). ```bash git push origin -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git fetch origin ``` 5. Make local branch "master" track remote branch "origin/master" (ie: remote branch "master" from remote "origin" which you just set above). See more syntax examples here: https://stackoverflow.com/a/2286030/4561887. ~~`git branch --set-upstream master origin/master`~~ (deprecated) -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git fetch origin ``` 5. Make local branch "master" track remote branch "origin/master" (ie: remote branch "master" from remote "origin" you just set above). See more syntax examples here: https://stackoverflow.com/a/2286030/4561887. ~~`git branch --set-upstream master origin/master`~~ (deprecated) -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git remote rename origin upstream ``` 3. Add a new origin which now points to your fork you just made above (instead of to to the original repository). ```bash git remote add origin git@github...my-fork -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git remote rename origin upstream ``` 3. Add a new origin which now points to your fork you just made above, instead of to to the original repository. ```bash git remote add origin git@github...my-fork -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,8 +27,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git fetch origin ``` 5. Make local branch "master" track remote branch "origin/master" (ie: remote branch "master" from remote "origin"). See more syntax examples here: https://stackoverflow.com/a/2286030/4561887. ~~`git branch --set-upstream master origin/master`~~ (deprecated) -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ To follow GitHub flow you should really have created a fork initially as a publi ``` 2. Manually [fork their repo](https://guides.github.com/activities/forking/) via the Github website directly. 3. In your local system, rename your **origin** remote to **upstream** ```bash git remote rename origin upstream -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git clone git@github...some-repo.git ``` 2. Manually [fork their repo](https://guides.github.com/activities/forking/) via the Github website directly. 3. In your local, rename your **origin** remote to **upstream** ```bash -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ To follow GitHub flow you should really have created a fork initially as a publi git clone git@github...some-repo.git ``` 2. Manually fork their repo via the [Github website](https://guides.github.com/activities/forking/) directly. 3. In your local, rename your **origin** remote to **upstream** ```bash -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,8 @@ To follow GitHub flow you should really have created a fork initially as a publi git fetch origin ``` 5. Make local branch "master" track remote branch "origin/master" (ie: remote branch "master" from remote "origin"): - See more syntax examples here: https://stackoverflow.com/a/2286030/4561887 ~~`git branch --set-upstream master origin/master`~~ (deprecated) -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ To follow GitHub flow you should really have created a fork initially as a publi 5. Set origin master ~~`git branch --set-upstream master origin/master`~~ (deprecated) ```bash git branch --set-upstream-to origin/master master -
ElectricRCAircraftGuy revised this gist
Jan 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ To follow GitHub flow you should really have created a fork initially as a publi 5. Set origin master ~~`git branch --set-upstream master origin/master`~~ #deprecated ```bash git branch --set-upstream-to origin/master master -
jpierson revised this gist
Mar 15, 2017 . 1 changed file with 12 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,16 +20,23 @@ To follow GitHub flow you should really have created a fork initially as a publi ```bash git remote add origin git@github...my-fork ``` 4. Fetch from new origin ```bash git fetch origin ``` 5. Set origin master ~~`git branch --set-upstream master origin/master`~~ ```bash git branch --set-upstream-to origin/master master ``` 6. Push to fork (origin should be able to omitted given step 4) ```bash git push origin ``` -
jpierson revised this gist
Mar 13, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ To follow GitHub flow you should really have created a fork initially as a publi 5. Fetch & push (origin should be able to omitted given step 4) ``` git fetch origin git push origin ``` -
jpierson revised this gist
Mar 13, 2017 . 1 changed file with 12 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,23 +11,25 @@ To follow GitHub flow you should really have created a fork initially as a publi 2. Fork their repo on [Github](https://guides.github.com/activities/forking/) 3. In your local, rename your **origin** remote to **upstream** ```bash git remote rename origin upstream ``` 3. Add a new origin ```bash git remote add origin git@github...my-fork ``` 4. Set origin master ```bash git branch --set-upstream master origin/master ``` 5. Fetch & push (origin should be able to omitted given step 4) ``` git fetch origin git push origin ``` -
jpierson revised this gist
Mar 13, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ To follow GitHub flow you should really have created a fork initially as a publi 1. Clone some repo (you've probably already done this step) ```bash git clone git@github...some-repo.git ``` 2. Fork their repo on [Github](https://guides.github.com/activities/forking/) 3. In your local, rename your **origin** remote to **upstream** -
jpierson revised this gist
Mar 13, 2017 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,6 @@ If you are like me you find yourself cloning a repo, making some proposed change To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as **origin** and the original forked repository as **upstream** so that you can use these keywords in other git commands. 1. Clone some repo (you've probably already done this step) ```bash -
jpierson revised this gist
Mar 13, 2017 . 2 changed files with 35 additions and 28 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,28 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ If you are like me you find yourself cloning a repo, making some proposed changes and then deciding to later contributing back using the [GitHub Flow](https://guides.github.com/introduction/flow/) convention. Below is a set of instructions I've developed for myself on how to deal with this scenario and an explanation of why it matters based on [jagregory's gist](https://gist.github.com/jagregory/710671). To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as **origin** and the original forked repository as **upstream** so that you can use these keywords in other git commands. * Off the top of my head * 1. Clone some repo (you've probably already done this step) ```bash git clone git@github...some-repo.git ``` 2. Fork their repo on [Github](https://guides.github.com/activities/forking/) 3. In your local, rename your **origin** remote to **upstream** ```bash git remote rename origin upstream ``` 3. Add a new origin ```bash git remote add origin git@github...my-fork ``` 4. Set origin master ```bash git branch --set-upstream master origin/master ``` 5. Fetch & push (origin should be able to omitted given step 4) git fetch origin git push origin -
jagregory created this gist
Nov 22, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear! Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy. * Off the top of my head * 1. Fork their repo on Github 2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it git remote add my-fork git@github...my-fork.git git fetch my-fork git push my-fork Otherwise, if you want to follow convention: 1. Fork their repo on Github 2. In your local, rename your origin remote to upstream git remote rename origin upstream 3. Add a new origin git remote add origin git@github...my-fork 4. Fetch & push git fetch origin git push origin