git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Allow worktree in same path with different gitdir

From
Carlos Pita <carlosjosepita@gmail.com>
Date
Apr 23, 2016, 19:41 UTC
Message-ID
<CAELgYheYazk+O1a9DH2ZbR4FgcuOTwa+Y+h_gfRs8w+e58rWNw@mail.gmail.com>
Hi all,

I usually keep my dotfiles, scripts, etc. in a git repo at ~, both as a backup solution and as a way to sync config between my different computers and remote servers in which I have to work. Some of these computers require a small number of local configurations that I like to keep in a repo too (mainly for backup purposes). These modifications to the base repo may be made branches of the base configuration but then keeping the common configurations in sync between all branches becomes cumbersome and error prone, with a lot of rebasing, cherry picking, stashing and whatnot. What I prefer is to create an orphan branch for local files, create a worktree for this branch, then move this worktree gitdir to something like ~/.gitlocal, next to the main ~/.git, update .git/worktrees to avoid pruning and define a handy alias like lgit='GIT_DIR=~/.gitlocal git'. This way I'm able to keep some files below ~ in a specific branch and some others in a shared master branch, all at the same time and in the same directory. What I find a bit cumbersome about this workflow is the inability to directly create the worktree at . specifying a gitdir like .gitlocal. Is there any fundamental reason this is not allowed for the worktree subcommand? If not, please consider this a feature request.

Notice the same is valid for cloning the ~ repo, instead of just creating a worktree from it. The clone subcommand will also reject a . path and also doesn't provide a way to specify a different gitdir (even --separate-git-dir requires a "fake" .git).

Cheers -- Carlos

Message 1 of 1 in “Allow worktree in same path with different gitdir”
  1. Carlos PitaApr 23, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.