1

I've forked Homebrew, branched to add a formula, and pushed to my fork.

Now I'm on a new machine, my fork is several (tens, hundreds, thousands of) commits behind.

The local Homebrew repo is thus a shallow clone, where my branch occurs in the distant and not-held past.

How can I fetch my fork into a local branch rebased onto master?

Anticipating "you can't with missing history", I would say - there's surely a way, when the patch is so simple as a few commits that add a single subsequently modified file?

OJFord
  • 10,522
  • 8
  • 64
  • 98
  • what issue do you have fetching your fixed branch from the fork? I believe it should be possible. You probably won't be able to merge then, because it won't find merge base, but rebase should be possible also – max630 Jan 03 '16 at 07:47

1 Answers1

0

You could export your branch as a series of patches from a repo where the branch is present:

git format-patch `git merge-base formula master`..formula

Copy those patches to your fork, and apply them with git am in a new branch on top of master

See "Patching with "git format-patch" and "git am"" as an example.

But the key point, of course, if that you have to have access first to a repo which includes your formula commits (to export them).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So if I was on a new install for example, I would clone both the newer history - viz. install homebrew - and, to a separate folder, the out of date repo with my branch, from which I could export? – OJFord Dec 31 '15 at 11:29
  • @oll yes, that is the idea: you need to access the older repo with your branch in it in order to export it. – VonC Dec 31 '15 at 11:31