public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Cc: GIT Mailing-list <git@vger.kernel.org>
Subject: Re: describe with --git-dir and --dirty outside of the repo always says dirty
Date: Fri, 13 Mar 2026 13:29:29 -0700	[thread overview]
Message-ID: <xmqq8qbv4gnq.fsf@gitster.g> (raw)
In-Reply-To: <99f2ba7e-cc5f-4ef5-9b09-85896563346f@virtuell-zuhause.de> (Thomas Braun's message of "Fri, 13 Mar 2026 20:02:58 +0100")

Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:

> When I do
>
> git describe --dirty
>
> in clean repo of git.git I get
>
> v2.53.0-522-g67006b9db8
>
> but when I do it from outside of the repo
>
> cd ..
> git --git-dir=git/.git describe --dirty

"--git-dir" tells git "I am at the root of the working tree, but the
git directory that you usually find at ".git" (or a parent directory
of where we are) is not where you expect but somewhere else, so I am
telling you where it is with this argument.

So if you are not at the root of the working tree for that working
tree, "git --git-dir=git/.git diff" would report that you have a ton
of changes to working tree files, and "describe" would report that
your working tree is dirty.

In other words, working as intended.

You can tell where the working tree is (instead of telling the
command that you are at the root of the working tree, when you are
not), with the "--work-tree" option.

$ git --git-dir=git/.git --work-tree=git describe --dirty

> Where should I start digging for a fix?

Between the keyboard and the chair ;-)?

Perhaps documentation for "--git-dir", GIT_DIR, "--work-tree", and
GIT_WORK_TREE should be studied, and if you find that they are
lacking, that is something we can fix.

Thanks.

  reply	other threads:[~2026-03-13 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 19:02 describe with --git-dir and --dirty outside of the repo always says dirty Thomas Braun
2026-03-13 20:29 ` Junio C Hamano [this message]
2026-03-16  8:22   ` Patrick Steinhardt
2026-03-18 17:33     ` Thomas Braun

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=xmqq8qbv4gnq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=thomas.braun@virtuell-zuhause.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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