{"thread":{"id":"13313","subject":"[DOC] more explanation about --git-dir and --work-tree options","startedAt":"2008-04-28T20:09:20Z","lastAt":"2008-04-29T21:30:04Z","messageCount":3,"participants":["Liu Yubao","しらいしななこ","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"75446","messageId":"48162EF0.6050705@gmail.com","threadId":"13313","inReplyTo":null,"subject":"[DOC] more explanation about --git-dir and --work-tree options","fromName":"Liu Yubao","fromEmail":"yubao.liu@gmail.com","sentAt":"2008-04-28T20:09:20Z","receivedAt":"2008-04-28T20:09:20Z","isPatch":false,"sender":{"key":"yubao.liu@gmail.com","avatar":null},"body":"Hi,\n\nI find these two options bring me surprise:\n\n   git init $HOME\n   git add ~/.vimrc ~/.gvimrc ~/.vim\n   cd $HOME/work/xxx\n   ....do some work, then change ~/.vimrc without changing\n       working directory\n   git --git-dir $HOME/.git status\n\nI use --git-dir because I have another .git in $HOME/work/xxx, the\nlast command surprises me much, it tells me .vim* are all deleted!\n\nAfter checking the code, I realize git thinks the current working\ndirectory as top directory of the working tree if --git-dir is specified\nwithout --work-tree option.\n\nI try to modify this behaviour so that git thinks the parent directory\nof .git/ as the top directory of my working tree, but later I find many\ntests are broken and I realize many scripts and many(??) git users would\nlike probably to work in the top directory of their working trees providing\nonly one extra --git-dir option with separated git repositories without\ntouching .git/config and environment variables, so I decide to give up\nmy patch and accustom myself to the new lovely core.worktree configuration\nvariable.\n\nAnd here is my supplement to the documentation.\n\n---\n Documentation/config.txt |    9 ++++++++-\n Documentation/git.txt    |   10 ++++++++--\n 2 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7a24f6e..307e089 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -234,7 +234,14 @@ core.worktree::\n \tused in combination with repositories found automatically in\n \ta .git directory (i.e. $GIT_DIR is not set).\n \tThis can be overridden by the GIT_WORK_TREE environment\n-\tvariable and the '--work-tree' command line option.\n+\tvariable and the '--work-tree' command line option. It can be\n+\ta absolute path or relative path to the directory specified by\n+\t--git-dir or GIT_DIR.\n+\tNote: If --git-dir or GIT_DIR are specified but none of\n+\t--work-tree, GIT_WORK_TREE and core.worktree is specified,\n+\tthe current working directory is regarded as the top directory\n+\tof your working tree.\n+\n \n core.logAllRefUpdates::\n \tEnable the reflog. Updates to a ref <ref> is logged to the file\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex a070e07..5b41e16 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -143,7 +143,8 @@ help ...'.\n \n --git-dir=<path>::\n \tSet the path to the repository. This can also be controlled by\n-\tsetting the GIT_DIR environment variable.\n+\tsetting the GIT_DIR environment variable. It can be an absolute\n+\tpath or relative path to current working directory.\n \n --work-tree=<path>::\n \tSet the path to the working tree.  The value will not be\n@@ -151,7 +152,12 @@ help ...'.\n \ta .git directory (i.e. $GIT_DIR is not set).\n \tThis can also be controlled by setting the GIT_WORK_TREE\n \tenvironment variable and the core.worktree configuration\n-\tvariable.\n+\tvariable. It can be an absolute path or relative path to\n+\tthe directory specified by --git-dir or GIT_DIR.\n+\tNote: If --git-dir or GIT_DIR are specified but none of\n+\t--work-tree, GIT_WORK_TREE and core.worktree is specified,\n+\tthe current working directory is regarded as the top directory\n+\tof your working tree.\n \n --bare::\n \tTreat the repository as a bare repository.  If GIT_DIR\n-- \n1.5.5\n"},{"id":"75679","messageId":"fv7g2s$g59$1@ger.gmane.org","threadId":"13313","inReplyTo":"48162EF0.6050705@gmail.com","subject":"Re: [DOC] more explanation about --git-dir and --work-tree options","fromName":"Michael J Gruber","fromEmail":"michaeljgruber+gmane@fastmail.fm","sentAt":"2008-04-29T15:49:44Z","receivedAt":"2008-04-29T15:49:44Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Liu Yubao venit, vidit, dixit 28.04.2008 22:09:\n> Hi,\n> \n> I find these two options bring me surprise:\n> \n>    git init $HOME\n>    git add ~/.vimrc ~/.gvimrc ~/.vim\n>    cd $HOME/work/xxx\n>    ....do some work, then change ~/.vimrc without changing\n>        working directory\n>    git --git-dir $HOME/.git status\n> \n> I use --git-dir because I have another .git in $HOME/work/xxx, the\n> last command surprises me much, it tells me .vim* are all deleted!\n> \n> After checking the code, I realize git thinks the current working\n> directory as top directory of the working tree if --git-dir is specified\n> without --work-tree option.\n\nYes, I found this surprising at first, too. And I noticed later on why \nthings are the way they are, just as you did. :)\n\nMore doc on this is certainly helpful.\n\n> And here is my supplement to the documentation.\n\n> +\tvariable and the '--work-tree' command line option. It can be\n> +\ta absolute path or relative path to the directory specified by\n\n\"an absolute path or a relative...\"\"\n\n> +\t--git-dir or GIT_DIR.\n> +\tNote: If --git-dir or GIT_DIR are specified but none of\n> +\t--work-tree, GIT_WORK_TREE and core.worktree is specified,\n\nI would probably interchange \"is\" and \"are\" here.\n\nSame changes in the following.\n\nI often find myself wanting to operate on a repo without cd'ing to it. While\n\n( cd repo && git command args)\n\nis certainly an option I find the following shell functions helpful:\n\nalias g=git\nfunction gg ()\n{\n   local _gg=\"$1\";\n   shift;\n   git --git-dir=\"${_gg}/.git\" --work-tree=\"${_gg}\" \"$@\"\n}\n\nThat way,\n\ngg repo command args\n\nruns git in a different location while\n\ng command args\n\nworks as usual (and is shorter).\n\nNow I'm just waiting for the experts to tell me that cd'ing to repo is \ncompletely different from specifying --git-dir and --work-tree, and that \neither way is completely wrong. (I'm still stupid and ugly, but I want \nto become clever and smart.) ;)\n\nMichael\n"},{"id":"75583","messageId":"200804292130.m3TLUcxl026222@mi0.bluebottle.com","threadId":"13313","inReplyTo":"48162EF0.6050705@gmail.com","subject":"Re: [DOC] more explanation about --git-dir and --work-tree options","fromName":"しらいしななこ","fromEmail":"nanako3@bluebottle.com","sentAt":"2008-04-29T21:30:04Z","receivedAt":"2008-04-29T21:30:04Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Liu Yubao <yubao.liu@gmail.com>:\n\n> I find these two options bring me surprise:\n>\n>    git init $HOME\n>    git add ~/.vimrc ~/.gvimrc ~/.vim\n>    cd $HOME/work/xxx\n>    ....do some work, then change ~/.vimrc without changing\n>        working directory\n>    git --git-dir $HOME/.git status\n>\n> I use --git-dir because I have another .git in $HOME/work/xxx, the\n> last command surprises me much, it tells me .vim* are all deleted!\n\nThe behavior at the end user level was outlined earlier in the message http://marc.info/?l=git&m=120390208721287&w=2\n\nA later message http://marc.info/?l=git&m=120445414611494&w=2 proposed an implementation change and described how the various pieces appear to programmers but it was lost when the code was scrapped.\n\nI think it is a good idea to add a documentation like this to at least describe the behavior visible by the end users.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n\n----------------------------------------------------------------------\nFinally - A spam blocker that actually works.\nhttp://www.bluebottle.com/tag/4\n"}]}