Skip to content

Instantly share code, notes, and snippets.

@mattpatterson94

mattpatterson94/README.md

Last active Feb 28, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.