Skip to content

Instantly share code, notes, and snippets.

@mas4112
Forked from benbalter/fork-a-branch.sh
Created April 21, 2021 09:19
Show Gist options
  • Select an option

  • Save mas4112/4dc232e496bebf3b71736e431e0b4b59 to your computer and use it in GitHub Desktop.

Select an option

Save mas4112/4dc232e496bebf3b71736e431e0b4b59 to your computer and use it in GitHub Desktop.
How to fork a single branch of a repo, preserving commit log
mkdir target-repo
cd target-repo
git init
git remote add origin git@github.com...
git remote add upstream git@github.com....
git fetch upstream
git pull upstream master
git push origin master
Alternative:
git clone git@github.com...
cd target-repo
git remote add upstream git@github.com....
git fetch upstream
git pull upstream master
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment