PSA: git worktree


#1

I just found out that the latest gits have a command called git-worktree: https://git-scm.com/docs/git-worktree

I know that several people who hack on rustc have told me in the past that they have multiple checkouts. Seems like it’d help a lot.


#2

Thanks! For anyone trying at home, it appears to have been added in Git 2.5.


#3

FWIW, similar functionality existed previously in the form of git-new-workdir, so people with older git’s can still get the functionality (I believe the script was available by default, at least on some Linuxes, under /usr/share/git-core/contrib/..., but I’m now on git 2.5, so I can’t check).


#4

The script did in fact come with the distribution, but wasn’t by default placed on the path (at least for me). I must say that git-new-workdir has been an extremely useful tool for me, and I’m definitely looking forward to switching to git-worktree (assuming it’s better :smile:)


#5

Note that the submodule support is still incomplete, according to the manual: “Multiple checkout in general is still experimental, and the support for submodules is incomplete. It is NOT recommended to make multiple checkouts of a superproject.”


#6

Regarding submodules, ./configure still pulls out all of them, so they exist in two (or more) copies. Also, worktree confuses git-gui for some reason.