Skip to content

Instantly share code, notes, and snippets.

@mattpatterson94
Last active February 28, 2017 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpatterson94/a553d748e6fcdf2a44f8bdada63ae0c4 to your computer and use it in GitHub Desktop.
Save mattpatterson94/a553d748e6fcdf2a44f8bdada63ae0c4 to your computer and use it in GitHub Desktop.
Cloning a repository by setting upstream and rebasing into master.

This is experimental. Methodology is questionable. Any feedback is welcome.

  • Take a parent repository git@github.com:Example/example.git
  • Take a child repository git@github.com:Example/child.git
cd child;
git checkout master;
git remote add upstream git@github.com:Example/example.git;
git checkout -b parent;
git push -u origin parent;
git branch -f --track parent upstream/master;
git checkout parent;
git checkout -b parent-merge;
git rebase -i -s recursive -X theirs master;

From here I reword the first commit to be Example Website and then fixup the rest of the commits.

:%s/pick/fixup/g - This will replace all pick with fixup

This means there will only be one commit for the previous site, just do condense the reflogs.

If you need to revert older commits (that won't be affected by the parent) I'd suggest not squashing.

Then push.

git push origin parent-merge;

This wont be an issue if the repo was empty before merge. At this point, you may want to review any files that have trailed from before the merge that are not needed. Would be interested to know about any good ways to remove these files easily, without having to go through everything.

Then PR into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment