From: Michael J Gruber <michaeljgruber+gmane@fastmail•fm>
To: git@vger•kernel.org
Subject: Re: [DOC] more explanation about --git-dir and --work-tree options
Date: Tue, 29 Apr 2008 17:49:44 +0200 [thread overview]
Message-ID: <fv7g2s$g59$1@ger.gmane.org> (raw)
In-Reply-To: <48162EF0.6050705@gmail.com>
Liu Yubao venit, vidit, dixit 28.04.2008 22:09:
> Hi,
>
> I find these two options bring me surprise:
>
> git init $HOME
> git add ~/.vimrc ~/.gvimrc ~/.vim
> cd $HOME/work/xxx
> ....do some work, then change ~/.vimrc without changing
> working directory
> git --git-dir $HOME/.git status
>
> I use --git-dir because I have another .git in $HOME/work/xxx, the
> last command surprises me much, it tells me .vim* are all deleted!
>
> After checking the code, I realize git thinks the current working
> directory as top directory of the working tree if --git-dir is specified
> without --work-tree option.
Yes, I found this surprising at first, too. And I noticed later on why
things are the way they are, just as you did. :)
More doc on this is certainly helpful.
> And here is my supplement to the documentation.
> + variable and the '--work-tree' command line option. It can be
> + a absolute path or relative path to the directory specified by
"an absolute path or a relative...""
> + --git-dir or GIT_DIR.
> + Note: If --git-dir or GIT_DIR are specified but none of
> + --work-tree, GIT_WORK_TREE and core.worktree is specified,
I would probably interchange "is" and "are" here.
Same changes in the following.
I often find myself wanting to operate on a repo without cd'ing to it. While
( cd repo && git command args)
is certainly an option I find the following shell functions helpful:
alias g=git
function gg ()
{
local _gg="$1";
shift;
git --git-dir="${_gg}/.git" --work-tree="${_gg}" "$@"
}
That way,
gg repo command args
runs git in a different location while
g command args
works as usual (and is shorter).
Now I'm just waiting for the experts to tell me that cd'ing to repo is
completely different from specifying --git-dir and --work-tree, and that
either way is completely wrong. (I'm still stupid and ugly, but I want
to become clever and smart.) ;)
Michael
next prev parent reply other threads:[~2008-04-30 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 20:09 [DOC] more explanation about --git-dir and --work-tree options Liu Yubao
2008-04-29 15:49 ` Michael J Gruber [this message]
2008-04-29 21:30 ` しらいしななこ
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fv7g2s$g59$1@ger.gmane.org' \
--to=michaeljgruber+gmane@fastmail$(echo .)fm \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox