Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Sep 2023 22:37:15 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Graham Perrin <grahamperrin@gmail.com>
Cc:        Alan Somers <asomers@freebsd.org>, freebsd-git <freebsd-git@freebsd.org>
Subject:   Re: Working with forks
Message-ID:  <CANCZdfrQiC3%2BbsYchsU7wWk3psW-rJ4ZY_O=GJ0G5PtMKpZ9vw@mail.gmail.com>
In-Reply-To: <CANCZdfqON9z_sA4gc6=iwg3RXfNPs62ZmxUfuJcs1u3ib5n7yw@mail.gmail.com>
References:  <7e6a3a98-80a8-c787-fda5-65e924dbad34@gmail.com> <CAOtMX2h1tZ3oC0a%2BMbizW9xK4Ryt5AaPtA%2B1C3g%2BTO4=vYo65A@mail.gmail.com> <543e12ed-bc12-ee0e-4ddf-4423fe704d78@gmail.com> <CANCZdfqBUbbdLGdZJT55LdJvNuZ8okF50Xs0i7C1HbRSKsa43g@mail.gmail.com> <CANCZdfqON9z_sA4gc6=iwg3RXfNPs62ZmxUfuJcs1u3ib5n7yw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000009b11cc0604d188fb
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Sep 7, 2023 at 10:30=E2=80=AFPM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Thu, Sep 7, 2023 at 8:51=E2=80=AFPM Warner Losh <imp@bsdimp.com> wrote=
:
>
>>
>>
>> On Thu, Sep 7, 2023, 8:39 PM Graham Perrin <grahamperrin@gmail.com>
>> wrote:
>>
>>> On 07/09/2023 20:03, Alan Somers wrote:
>>> > On Thu, Sep 7, 2023 at 11:49=E2=80=AFAM Graham Perrin <grahamperrin@g=
mail.com>
>>> wrote:
>>> >> With a clone of e.g. https://github.com/freebsd/freebsd-src.git (in
>>> the FreeBSD project) as a starting point: when the times come to work,
>>> locally, with other people's forks, does Git (at the command line) allo=
w an
>>> easy way to temporarily use the same local directory?
>>> > I do this all the time, if I understand the question correctly.  You
>>> > just need to add a separate git remote for each fork.  For example,
>>> > this sequence of commands will clone the FreeBSD source.  Then it wil=
l
>>> > fetch grahamperrin's fork.  Then it will checkout a copy of
>>> > grahamperrin's feature branch.  Finally, it will rebase that feature
>>> > branch onto a branch from the original FreeBSD repo.
>>> >
>>> > git clone git@github.com/freebsd/freebsd-src.git
>>> > cd freebsd-src
>>> > git remote add grahamperrin
>>> git@github.com/grahamperrin/freebsd-src.git
>>> > git fetch grahamperrin
>>> > git branch grahamperrin/featureX featureX
>>> > git checkout featureX
>>> > git rebase origin/stable/13
>>>
>>> Thanks.
>>>
>>> Below (an abbreviated list of branches), what am I doing wrong?
>>>
>>> % git -C /usr/src config --get remote.origin.url
>>> https://github.com/grahamperrin/freebsd-src.git
>>> % git -C /usr/src remote add jlduran
>>> https://github.com/jlduran/freebsd-src.git
>>> % git -C /usr/src fetch jlduran
>>>  From https://github.com/jlduran/freebsd-src
>>>   * [new branch] D37210                                  ->
>>> jlduran/D37210
>>> =E2=80=A6
>>>   * [new branch] nanobsd-embedded-use-makefs             ->
>>> jlduran/nanobsd-embedded-use-makefs
>>> =E2=80=A6
>>>   * [new branch] wip-fix-comment-blah                    ->
>>> jlduran/wip-fix-comment-blah
>>> % git -C /usr/src branch jlduran/nanobsd-embedded-use-makefs
>>> nanobsd-embedded-use-makefs
>>> fatal: not a valid object name: 'nanobsd-embedded-use-makefs'
>>> %
>>>
>>> If it's relevant: my /usr/src originated from my fork.
>>>
>>
>>
>> I never use -C... but 'git checkout nanobsd-embedded-use-makefs' may
>> work. Or 'git checkout -t jlduran/nanobsd-embedded-use-makefs' if not. T=
he
>> latter will definitely work. The git branch command never does what I wa=
nt
>> so I never use it  (except for variants like -d or --sort).
>>
>
> My typical work flow looks more like:
>
> % git remote add bruno httpsg:ithub.com/seanbruno/qemu-bsd-user.git
> % git fetch bruno
> % git checkout -t bruno/gerbils
> (to get the gerbils branch from bruno created as well, to track the
> remote, but this
>  specific one is ancient history at this point).
> or sometimes
> % git worktree add ../qemu-bruno bruno/gerbils
>

Or in this case I just did:

% git remote add jlduran ssh://git@github.com/jlduran/freebsd-src.git
% git fetch jlduran
% git checkout nanobsd-embedded-use-makefs

and it created the tracking branch against
jlduran/nanobsd-embedded-use-makefs for me.
Other guides and people suggest adding the -t  and using the upstream name
to do it.
I'm not sure what to recommend, but I know the above works.

I also never have a /usr/src on any of my systems. Too many work trees for
larger
work in progress or review-in-progress projects. When I do have /usr/src,
it's always
exactly what's on the machine (or I'm building the new version). It got too
confusing
for me in the 90s having this in /usr/src (though to be fair, it was the
era of CVS which
made easy things hard, and hard things impossible).

Warner

--0000000000009b11cc0604d188fb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Thu, Sep 7, 2023 at 10:30=E2=80=AF=
PM Warner Losh &lt;<a href=3D"mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;=
 wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">On Thu, Sep 7, 2023 at 8:51=E2=80=AFPM Warner=
 Losh &lt;<a href=3D"mailto:imp@bsdimp.com" target=3D"_blank">imp@bsdimp.co=
m</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"=
><div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr"=
 class=3D"gmail_attr">On Thu, Sep 7, 2023, 8:39 PM Graham Perrin &lt;<a hre=
f=3D"mailto:grahamperrin@gmail.com" target=3D"_blank">grahamperrin@gmail.co=
m</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"=
>On 07/09/2023 20:03, Alan Somers wrote:<br>
&gt; On Thu, Sep 7, 2023 at 11:49=E2=80=AFAM Graham Perrin &lt;<a href=3D"m=
ailto:grahamperrin@gmail.com" rel=3D"noreferrer" target=3D"_blank">grahampe=
rrin@gmail.com</a>&gt; wrote:<br>
&gt;&gt; With a clone of e.g. <a href=3D"https://github.com/freebsd/freebsd=
-src.git" rel=3D"noreferrer noreferrer" target=3D"_blank">https://github.co=
m/freebsd/freebsd-src.git</a> (in the FreeBSD project) as a starting point:=
 when the times come to work, locally, with other people&#39;s forks, does =
Git (at the command line) allow an easy way to temporarily use the same loc=
al directory?<br>
&gt; I do this all the time, if I understand the question correctly.=C2=A0 =
You<br>
&gt; just need to add a separate git remote for each fork.=C2=A0 For exampl=
e,<br>
&gt; this sequence of commands will clone the FreeBSD source.=C2=A0 Then it=
 will<br>
&gt; fetch grahamperrin&#39;s fork.=C2=A0 Then it will checkout a copy of<b=
r>
&gt; grahamperrin&#39;s feature branch.=C2=A0 Finally, it will rebase that =
feature<br>
&gt; branch onto a branch from the original FreeBSD repo.<br>
&gt;<br>
&gt; git clone <a href=3D"http://git@github.com/freebsd/freebsd-src.git" re=
l=3D"noreferrer noreferrer" target=3D"_blank">git@github.com/freebsd/freebs=
d-src.git</a><br>
&gt; cd freebsd-src<br>
&gt; git remote add grahamperrin <a href=3D"http://git@github.com/grahamper=
rin/freebsd-src.git" rel=3D"noreferrer noreferrer" target=3D"_blank">git@gi=
thub.com/grahamperrin/freebsd-src.git</a><br>
&gt; git fetch grahamperrin<br>
&gt; git branch grahamperrin/featureX featureX<br>
&gt; git checkout featureX<br>
&gt; git rebase origin/stable/13<br>
<br>
Thanks.<br>
<br>
Below (an abbreviated list of branches), what am I doing wrong?<br>
<br>
% git -C /usr/src config --get remote.origin.url<br>
<a href=3D"https://github.com/grahamperrin/freebsd-src.git" rel=3D"noreferr=
er noreferrer" target=3D"_blank">https://github.com/grahamperrin/freebsd-sr=
c.git</a><br>
% git -C /usr/src remote add jlduran <br>
<a href=3D"https://github.com/jlduran/freebsd-src.git" rel=3D"noreferrer no=
referrer" target=3D"_blank">https://github.com/jlduran/freebsd-src.git</a><=
br>
% git -C /usr/src fetch jlduran<br>
=C2=A0From <a href=3D"https://github.com/jlduran/freebsd-src" rel=3D"norefe=
rrer noreferrer" target=3D"_blank">https://github.com/jlduran/freebsd-src</=
a><br>
=C2=A0=C2=A0* [new branch] D37210=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 -&gt; jlduran/D37210<br>
=E2=80=A6<br>
=C2=A0=C2=A0* [new branch] nanobsd-embedded-use-makefs=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -&gt; <br>
jlduran/nanobsd-embedded-use-makefs<br>
=E2=80=A6<br>
=C2=A0=C2=A0* [new branch] wip-fix-comment-blah=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 -&gt; <br>
jlduran/wip-fix-comment-blah<br>
% git -C /usr/src branch jlduran/nanobsd-embedded-use-makefs <br>
nanobsd-embedded-use-makefs<br>
fatal: not a valid object name: &#39;nanobsd-embedded-use-makefs&#39;<br>
%<br>
<br>
If it&#39;s relevant: my /usr/src originated from my fork.<br></blockquote>=
</div></div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div di=
r=3D"auto">I never use -C... but &#39;git checkout nanobsd-embedded-use-mak=
efs&#39; may work. Or &#39;git checkout -t jlduran/nanobsd-embedded-use-mak=
efs&#39; if not. The latter will definitely work. The git branch command ne=
ver does what I want so I never use it=C2=A0 (except for variants like -d o=
r --sort).</div></div></blockquote><div><br></div><div>My typical work flow=
 looks more like:</div><div><br></div><div>% git remote add bruno httpsg:<a=
 href=3D"http://ithub.com/seanbruno/qemu-bsd-user.git" target=3D"_blank">it=
hub.com/seanbruno/qemu-bsd-user.git</a></div><div>% git fetch bruno</div><d=
iv>% git checkout -t bruno/gerbils</div><div>(to get the gerbils branch fro=
m bruno created as well, to track the remote, but this</div><div>=C2=A0spec=
ific one is ancient history at this point).</div><div>or sometimes</div><di=
v>% git worktree add ../qemu-bruno bruno/gerbils</div></div></div></blockqu=
ote><div><br></div><div>Or in this case I just did:</div><div><br></div><di=
v>%=C2=A0git remote add jlduran ssh://<a href=3D"http://git@github.com/jldu=
ran/freebsd-src.git">git@github.com/jlduran/freebsd-src.git</a></div><div>%=
 git fetch jlduran</div><div>% git checkout nanobsd-embedded-use-makefs</di=
v><div><br></div><div>and it created the tracking branch against jlduran/na=
nobsd-embedded-use-makefs=C2=A0for me.</div><div>Other guides and people su=
ggest adding the -t=C2=A0 and using the upstream name to do it.</div><div>I=
&#39;m not sure what to recommend, but I know the above works.</div><div><b=
r></div><div>I also never have a /usr/src on any of my systems. Too many wo=
rk trees for larger</div><div>work in progress or review-in-progress projec=
ts. When I do have /usr/src, it&#39;s always</div><div>exactly what&#39;s o=
n the machine (or I&#39;m building the new version). It got too confusing</=
div><div>for me in the 90s having this in /usr/src (though to be fair, it w=
as the era of CVS which</div><div>made easy things hard, and hard things im=
possible).</div><div><br></div><div>Warner</div></div></div>

--0000000000009b11cc0604d188fb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrQiC3%2BbsYchsU7wWk3psW-rJ4ZY_O=GJ0G5PtMKpZ9vw>