this post was submitted on 31 Jul 2025
24 points (96.2% liked)

General Programming Discussion

8852 readers
2 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] SpaceNoodle@lemmy.world 5 points 2 weeks ago (3 children)

What benefits does this provide over a cloned copy of the repository?

[–] atzanteol@sh.itjust.works 4 points 2 weeks ago (1 children)

It's more space efficient - you don't get another full copy of the repo. The worktree points back to the same .git directory.

And since it's in the same repo you can diff between branches with other worktrees without needing to setup remotes for each of them.

[–] SpaceNoodle@lemmy.world 1 points 2 weeks ago (1 children)

You can already diff between branches in a single worktree.

[–] atzanteol@sh.itjust.works 1 points 2 weeks ago (1 children)
[–] SpaceNoodle@lemmy.world 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Then why mention setting up remotes? Why would multiple worktrees help if a worktree is not necessary for the functionality?

[–] atzanteol@sh.itjust.works 2 points 2 weeks ago

The question I was answering was about worktrees vs. multiple clones. With multiple clones you need to setup remotes to share branches between directories. With worktrees sharing a working copy you don't.

[–] dessalines@lemmy.ml 3 points 2 weeks ago

No need for another full git history copy, nor submodules and settings.

[–] eldavi@lemmy.ml 1 points 2 weeks ago (1 children)

every time i do this, i have to annotate the old copy somehow.

i usually use a date and months later i have no clue why i made the copy.

[–] SpaceNoodle@lemmy.world 3 points 2 weeks ago (1 children)

Yes, you should name directories descriptively. I don't think that's unique to repository clones.

[–] eldavi@lemmy.ml 1 points 2 weeks ago (1 children)

definately not since that's the way i learned.

the problem is that a directory named master-hotfix-vgpool01-05022022 is very difficult to remember why it was created if you looked at it today.

[–] SpaceNoodle@lemmy.world 2 points 2 weeks ago (1 children)

Then clearly it was poorly named.

[–] eldavi@lemmy.ml 0 points 2 weeks ago (1 children)
[–] SpaceNoodle@lemmy.world -1 points 2 weeks ago

Something that clearly communicates its purpose.