Subject: [bug#52346] Using git worktrees

From: Efraim Flashner <[email-masked]>
Date: Wed, 8 Dec 2021 11:30:50 +0200

On Tue, Dec 07, 2021 at 04:28:30PM -0500, jgart wrote:
> On Tue, 07 Dec 2021 13:50:52 +0200 Efraim Flashner <[email-masked]> wrote:
> > On Tue, Dec 07, 2021 at 05:02:58AM -0500, jgart via Guix-patches via wrote:
> > > On Tue, 07 Dec 2021 09:26:51 +0100 Liliana Marie Prikler <[email-masked]> wrote:
> > > > This has already been taken care of on core-updates-frozen [1], have
> > > > some patience ;)
> > > 
> > > hahah
> > > 
> > > How do you usually keep up to date with core-updates-frozen, etc...?
> > > 
> > > rss feeds, email list for cuf?
> > > 
> > 
> > git worktrees :)
> 
> Efraim,
> 
> What's your workflow for using git worktrees when doing Guix development?
> 
> I remember Raghav using them and he showed me briefly but it felt a bit
> like a branches, maybe cleaner for bootstrapping and switching to a new
> tree. I didn't get around to incorporating it into my own workflow.
> 
> Any advice is much appreciated,
> 
> jgart

It's quite expensive with Guix to switch between different branches due
to the compiled guile code. By keeping different branches in different
directories I can work on them concurrently without needing to recompile
when switching between branches. It's basically like checking out the
repository multiple times in different directories, but they all use the
.git folder from the original checkout.

(ins)efraim@3900XT ~/workspace/guix$ git worktree list
/home/efraim/workspace/guix                   ddcec589bc [master]
/home/efraim/workspace/guix-core-updates      ee03b51f6e [core-updates-frozen]
/home/efraim/workspace/guix-riscv             34758aca7c [wip-riscv]
/home/efraim/workspace/guix-staging           eec94982b1 [staging]
/home/efraim/workspace/guix-upstream-keyring  702f4c7942 [keyring]
/home/efraim/workspace/guix-wip-rust          ed496cb639 [wip-rust]

The basic command I follow is 'git worktree add <path> <branch>', so
'git worktree add ../guix-core-updates origin/core-updates-frozen'. Then
I change it to what I actually wanted, a local branch named
core-updates, tracking origin/core-updates-frozen (I can never get some
of those commands correct). Then I run bootstrap, configure and make in
that directory and I can work on both branches at the same time.

I'm not sure about the syntax since I often seem to get the worktree and
branching syntax wrong (and end up creating a local branch named
origin/core-updates, tracking my local core-updates branch), but it's
great for keeping track of everything at once.

Once most of my wip-riscv branch is merged back in I'll remove the
actual worktree with 'git worktree remove <something>' and then just
keep the wip-riscv branch.

-- 
Efraim Flashner   <[email-masked]>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted