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>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] On Thu, Sep 7, 2023 at 10:30 PM Warner Losh <imp@bsdimp.com> wrote: > > > On Thu, Sep 7, 2023 at 8:51 PM 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 AM Graham Perrin <grahamperrin@gmail.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) allow 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 will >>> > 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 >>> … >>> * [new branch] nanobsd-embedded-use-makefs -> >>> jlduran/nanobsd-embedded-use-makefs >>> … >>> * [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. The >> latter will definitely work. The git branch command never does what I want >> 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 [-- Attachment #2 --] <div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 7, 2023 at 10:30 PM Warner Losh <<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 7, 2023 at 8:51 PM Warner Losh <<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 7, 2023, 8:39 PM Graham Perrin <<a href="mailto:grahamperrin@gmail.com" target="_blank">grahamperrin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="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> > On Thu, Sep 7, 2023 at 11:49 AM Graham Perrin <<a href="mailto:grahamperrin@gmail.com" rel="noreferrer" target="_blank">grahamperrin@gmail.com</a>> wrote:<br> >> With a clone of e.g. <a href="https://github.com/freebsd/freebsd-src.git" rel="noreferrer noreferrer" target="_blank">https://github.com/freebsd/freebsd-src.git</a> (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) allow an easy way to temporarily use the same local directory?<br> > I do this all the time, if I understand the question correctly. You<br> > just need to add a separate git remote for each fork. For example,<br> > this sequence of commands will clone the FreeBSD source. Then it will<br> > fetch grahamperrin's fork. Then it will checkout a copy of<br> > grahamperrin's feature branch. Finally, it will rebase that feature<br> > branch onto a branch from the original FreeBSD repo.<br> ><br> > git clone <a href="http://git@github.com/freebsd/freebsd-src.git" rel="noreferrer noreferrer" target="_blank">git@github.com/freebsd/freebsd-src.git</a><br> > cd freebsd-src<br> > git remote add grahamperrin <a href="http://git@github.com/grahamperrin/freebsd-src.git" rel="noreferrer noreferrer" target="_blank">git@github.com/grahamperrin/freebsd-src.git</a><br> > git fetch grahamperrin<br> > git branch grahamperrin/featureX featureX<br> > git checkout featureX<br> > 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="https://github.com/grahamperrin/freebsd-src.git" rel="noreferrer noreferrer" target="_blank">https://github.com/grahamperrin/freebsd-src.git</a><br> % git -C /usr/src remote add jlduran <br> <a href="https://github.com/jlduran/freebsd-src.git" rel="noreferrer noreferrer" target="_blank">https://github.com/jlduran/freebsd-src.git</a><br> % git -C /usr/src fetch jlduran<br> From <a href="https://github.com/jlduran/freebsd-src" rel="noreferrer noreferrer" target="_blank">https://github.com/jlduran/freebsd-src</a><br> * [new branch] D37210 -> jlduran/D37210<br> …<br> * [new branch] nanobsd-embedded-use-makefs -> <br> jlduran/nanobsd-embedded-use-makefs<br> …<br> * [new branch] wip-fix-comment-blah -> <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: 'nanobsd-embedded-use-makefs'<br> %<br> <br> If it's relevant: my /usr/src originated from my fork.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">I never use -C... but 'git checkout nanobsd-embedded-use-makefs' may work. Or 'git checkout -t jlduran/nanobsd-embedded-use-makefs' if not. The latter will definitely work. The git branch command never does what I want so I never use it (except for variants like -d or --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="http://ithub.com/seanbruno/qemu-bsd-user.git" target="_blank">ithub.com/seanbruno/qemu-bsd-user.git</a></div><div>% git fetch bruno</div><div>% git checkout -t bruno/gerbils</div><div>(to get the gerbils branch from bruno created as well, to track the remote, but this</div><div> specific one is ancient history at this point).</div><div>or sometimes</div><div>% git worktree add ../qemu-bruno bruno/gerbils</div></div></div></blockquote><div><br></div><div>Or in this case I just did:</div><div><br></div><div>% git remote add jlduran ssh://<a href="http://git@github.com/jlduran/freebsd-src.git">git@github.com/jlduran/freebsd-src.git</a></div><div>% git fetch jlduran</div><div>% git checkout nanobsd-embedded-use-makefs</div><div><br></div><div>and it created the tracking branch against jlduran/nanobsd-embedded-use-makefs for me.</div><div>Other guides and people suggest adding the -t and using the upstream name to do it.</div><div>I'm not sure what to recommend, but I know the above works.</div><div><br></div><div>I also never have a /usr/src on any of my systems. Too many work trees for larger</div><div>work in progress or review-in-progress projects. When I do have /usr/src, it's always</div><div>exactly what's on the machine (or I'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 was the era of CVS which</div><div>made easy things hard, and hard things impossible).</div><div><br></div><div>Warner</div></div></div>help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrQiC3%2BbsYchsU7wWk3psW-rJ4ZY_O=GJ0G5PtMKpZ9vw>
