Skip to content

Instantly share code, notes, and snippets.

@cowboy-bebug
Created April 28, 2020 06:30
Show Gist options
  • Save cowboy-bebug/d976ccfbbb45a4763d9600fc6aac0f13 to your computer and use it in GitHub Desktop.
Save cowboy-bebug/d976ccfbbb45a4763d9600fc6aac0f13 to your computer and use it in GitHub Desktop.
Fork a subdirectory of an upstream repo
# clone an upstream repo
git clone https://github.com/<user>/<project>.git && cd project
git branch -m upstream-master
git subtree split --prefix=<folder>/<subfolder> -b upstream-rebase
git checkout upstream-rebase
git remote rename origin upstream
git remote add origin https://github.com/<my-account>/<my-project>.git
git fetch origin
git push -u origin upstream-rebase
git checkout -b master
git push -u origin master
# To merge upstream changes
git checkout upstream-master
git pull
git subtree split --prefix=<folder>/<subfolder> --onto upstream-rebase -b upstream-rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment