From: Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>
To: "Ulrich Windl" <Ulrich.Windl@rz•uni-regensburg.de>
Cc: <git@vger•kernel.org>
Subject: Re: Q: ".git/HEAD" and ".git/refs/heads"
Date: Wed, 02 Apr 2014 19:54:00 +0200 [thread overview]
Message-ID: <vpqob0jwrbb.fsf@anie.imag.fr> (raw)
In-Reply-To: <533C404F020000A1000151CE@gwsmtp1.uni-regensburg.de> (Ulrich Windl's message of "Wed, 02 Apr 2014 16:52:31 +0200")
"Ulrich Windl" <Ulrich.Windl@rz•uni-regensburg.de> writes:
> Hi!
>
> I have a small question: After a "git gc" with last commit being "[shared 2679648]" I found this:
>> cat .git/HEAD
> ref: refs/heads/shared
>> cat .git/refs/heads/shared
> cat: .git/refs/heads/shared: No such file or directory
>
> Is this intentional?
Yes.
> commit in these files: .git/logs/HEAD .git/logs/refs/heads/shared
> .git/info/refs .git/packed-refs
Yes, they are where the refs are stored. If you have many refs in your
repository, having one file per ref is inefficient. It's more efficient
for Git to have one big read-only file. When one ref is modified, the
.git/refs/heads/$branch file is re-created, and the packed entry is
ignored.
> if [ -d .git ]; then
> GIT_HEAD="$(<.git/HEAD)"
> GIT_BRANCH="${GIT_HEAD##*/}"
> GIT_HEAD="Git:$GIT_BRANCH-$(cut -c1-7 .git/${GIT_HEAD##*: })"
> fi
Don't access the filesystem. Ask Git.
GIT_FULL_BRANCH=$(git rev-parse --symbolic-full-name HEAD)
GIT_BRANCH="${GIT_FULL_BRANCH##*/}"
GIT_HEAD="Git:$GIT_BRANCH-$(git rev-parse --short HEAD)"
(Perhaps there's a simpler way without $GIT_FULL_BRANCH)
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2014-04-03 10:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-02 14:52 Q: ".git/HEAD" and ".git/refs/heads" Ulrich Windl
2014-04-02 17:54 ` Matthieu Moy [this message]
2014-04-03 8:04 ` Antw: " Ulrich Windl
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=vpqob0jwrbb.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp$(echo .)fr \
--cc=Ulrich.Windl@rz$(echo .)uni-regensburg.de \
--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