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

inconsistent use of worktree?

From
MKmartin f krafft <madduck@madduck.net>
Date
Sep 6, 2007, 13:29 UTC
Message-ID
<20070906132906.GA7791@piper.oerlikon.madduck.net>
Hi there,

I have a $GIT_DIR in ~/.bin/colgit.git, which is bare=false and has worktree=.. (the parent). This relates back to a suggestion by Johannes Schindelin [0] for maintaining files like ~/.vimrc and ~/.zshrc in separate repos sharing the same worktree. In short: while ~/.bin/colgit.git holds all of colgit's objects, refs, and the index, the repository's files are in ~/.bin (and thus in $PATH).

0. http://marc.info/?l=git&m=118418927823760&w=2

I am trying to figure out a sensible way to work with this, ideally one which does not require me to set $GIT_DIR (which works):

  GIT_DIR=~/.bin/colgit.git git status
  GIT_DIR=~/.bin/colgit.git git add ...
  GIT_DIR=~/.bin/colgit.git git commit ...
  (or one export GIT_DIR)
but that's a lot of typing and thus error-prone.
So in a flash of utter genius, I found this to work:
  piper:~/.bin/colgit.git> git status
  # On branch master
  # Changed but not updated:
  #   (use "git add <file>..." to update what will be committed)
  #
  #       modified:   colgit
  #
  no changes added to commit (use "git add" and/or "git commit -a")
  piper:~/.bin/colgit.git> git add ../colgit
  piper:~/.bin/colgit.git> git status
  # On branch master
  # Changes to be committed:
  #   (use "git reset HEAD <file>..." to unstage)
  #
  #       modified:   colgit

and I rejoiced, because that's really pretty cool. But then, trying to commit, reality hit back:

  piper:~/.bin/colgit.git> git commit -m'initial commit'
  nothing to commit (use "git add file1 file2" to include for commit)
So I had to revert to using GIT_DIR for this:
  piper:~/.bin> GIT_DIR=colgit.git git commit -m'initial commit'
  Created initial commit 008594d: initial commit
   1 files changed, 104 insertions(+), 0 deletions(-)
   create mode 100755 colgit

And then things got really weird, after I accidentally tried the direct commit (without GIT_DIR) again, following some touchups I made to the colgit file:

  piper:~/.bin/colgit.git> git commit -m'repairing registration and other touchups'
  Created commit acd86b9: Merge branch 'vimplate'
Huh, vimplate? What happened to the commit? Why vimplate?
  piper:~/.bin/colgit.git> git log
  commit 0ad26b00c31617bf3e31a052e3c3af9ef661407b
  Author: martin f. krafft <madduck@madduck.net>
  Date:   Thu Sep 6 11:45:38 2007 +0200
      repairing registration and other touchups
  [...]

But the commit appears alright, acd86b9 is the tip of ~/.git, further up, and the output of git-rev-parse HEAD in ~/.bin, the parent directory and worktree of ~/.bin/colgit.git.

What is git doing? Could it be that it's getting utterly confused and inconsistently uses the worktree? I'd be happy to investigate this, but want to make sure I am not doing anything wrong!

Cheers,
-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
"there are more things in heaven and earth, horatio,
 than are dreamt of in your philosophy."
                                                             -- hamlet
 
spamtraps: madduck.bogus@madduck.net
Next: martin f krafft
Message 1 of 3 in “inconsistent use of worktree?”
  1. martin f krafftSep 6, 2007
  2. martin f krafftSep 6, 2007
  3. inconsistent use of worktree? (resend)martin f krafft, Sep 15, 2007

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.