top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

detached HEAD before root commit - possible, using GIT?

0 votes

I suspect that detaching HEAD before a root commit is not possible by design. What would HEAD contain then!? 'git checkout' seems to corroborate:

$ git init
Initialized empty Git repository in /tmp/test/.git/
$ git checkout --detach
fatal: You are on a branch yet to be born

Are there some plumbing commands and options that would still allow this, or can I rely on that that it's impossible?

posted Jun 23, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

gitrepository-layout(5) tells me HEAD can be in one of a few states:

a) Missing. In this case the repository is considered to be corrupt and attempts to access the repository fail until the user runs "git init" to recover.

b) A symbolic link, which is one way to represent a symref (pointing to an existing branch or an unborn branch).

c) A standard symref, in the format "ref: refs/some/branch". Behaves like (b).

d) A direct SHA-1 reference (40-character commit object name) pointing to a commit without associating a branch ("detached HEAD").

e) Anything else means the repository is corrupt, as in case (a).

In other words, HEAD always either points to an unborn or existing branch or an existing commit. It's not clear to me what it would mean to detach from an unborn branch.

answer Jun 24, 2013 by anonymous
Similar Questions
0 votes

I want to show commit related information by the command below.By this, committed files are shown, but names only, off course.But in addition to this, I want to show commit file types (New, Edited, and Deleted).What argument should I use in the command?
git --no-pager show --format=%h%n%an%n%ai%n%s --name-only

0 votes

After I resolved conflict, how can I do commit by using ".git/MERGE_MSG" without editor ?

I did like below but It didn't work.

$ cat .git/MERGE_MSG | git commit -m 

Is there any way?

+2 votes

Could somebody tell me how to make git rebase -i show diff of squashed commits (for example), like git commit -v does it?

+2 votes

Is it possible to add custom metadata to Git commit object?
Such metadata should be ignored by Git commands, but could be used by a 3-party tool which knows the format and knows where to look.

I assume that this should be possible, given that Git objects are actually patches, and patches can contain additional details. But can this be done with the help of Git commands?