threads / discuss / 46118

What does this output of git supposed to mean ?

Subject: What does this output of git supposed to mean ?

## tl;dr

17 messages between Jun 5, 2017 and Jun 7, 2017.

replies: 16people: 9as markdown or json

Kaartic Sivaraam· Jun 5, 2017, 14:04 UTC · lore
Hello all,

I noticed a weird output by git when trying to run 'git status' on a newly initialized git repository. It prints the following,

Show 5 quoted lines
> On branch master
> 
> Initial commit
> 
> nothing to commit (create/copy files and use "git add" to track)
What's that "Initial commit" supposed to mean?
-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
brian m. carlson· Jun 5, 2017, 23:10 UTC · re: Kaartic Sivaraam · lore

Re: What does this output of git supposed to mean ?

On Mon, Jun 05, 2017 at 07:34:12PM +0530, Kaartic Sivaraam wrote:
Show 13 quoted lines
> Hello all,
> 
> I noticed a weird output by git when trying to run 'git status' on a
> newly initialized git repository. It prints the following,
> 
> > On branch master
> > 
> > Initial commit
> > 
> > nothing to commit (create/copy files and use "git add" to track)
> 
> 
> What's that "Initial commit" supposed to mean?

It just means that it will be the first commit in the repository. It's a helpful reminder that some operations (such as git log) won't work as expected. In addition, many people want to commit certain files (such as .gitignore) in their initial commit, and this may jog their memory.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Stefan Beller· Jun 5, 2017, 23:18 UTC · re: brian m. carlson · lore

Re: What does this output of git supposed to mean ?

On Mon, Jun 5, 2017 at 4:10 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 19 quoted lines
> On Mon, Jun 05, 2017 at 07:34:12PM +0530, Kaartic Sivaraam wrote:
>> Hello all,
>>
>> I noticed a weird output by git when trying to run 'git status' on a
>> newly initialized git repository. It prints the following,
>>
>> > On branch master
>> >
>> > Initial commit
>> >
>> > nothing to commit (create/copy files and use "git add" to track)
>>
>>
>> What's that "Initial commit" supposed to mean?
>
> It just means that it will be the first commit in the repository.  It's
> a helpful reminder that some operations (such as git log) won't work as
> expected.  In addition, many people want to commit certain files (such
> as .gitignore) in their initial commit, and this may jog their memory.
Tangent:
For any personal project (or git repository that I start)
I find myself doing one of the following:
1) I think about implications of the git history. And from what I understand
  there are a couple of issues with the very first commit (e.g.
  interactive rebase needs special flags to start from the 0-th commit)
  In this case I run git commit --allow-empty -m "initial commit"
  first and then proceed doing whatever
2. I do not think about history, so the first commit is a
  git commit -a -m "I made a shiny thing", ignoring any advice
  git gave me...

On the subject: maybe we want to rename initial commit to root commit? (evil-me also thinks we could name it "parent-less commit", to reinforce what the lovely git man page generator tries to point at.)

Junio C Hamano· Jun 6, 2017, 01:00 UTC · re: Stefan Beller · lore

Re: What does this output of git supposed to mean ?

Stefan Beller <sbeller@google.com> writes:
> On the subject: maybe we want to rename initial commit
> to root commit? (evil-me also thinks we could name it
> "parent-less commit", to reinforce what the lovely git man
> page generator tries to point at.)
Is "initial" harder to understand than "root" or "parent-less"?
brian m. carlson· Jun 6, 2017, 01:11 UTC · re: Junio C Hamano · lore

Re: What does this output of git supposed to mean ?

On Tue, Jun 06, 2017 at 10:00:12AM +0900, Junio C Hamano wrote:
Show 8 quoted lines
> Stefan Beller <sbeller@google.com> writes:
> 
> > On the subject: maybe we want to rename initial commit
> > to root commit? (evil-me also thinks we could name it
> > "parent-less commit", to reinforce what the lovely git man
> > page generator tries to point at.)
> 
> Is "initial" harder to understand than "root" or "parent-less"?

I personally think that "Initial commit" is very straightforward. If we get more inquiries about it, we could consider changing it, but seeing as this is the first question I've ever seen about it, I think most people understand it pretty well.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Samuel Lijin· Jun 6, 2017, 01:39 UTC · re: brian m. carlson · lore

Re: What does this output of git supposed to mean ?

On Mon, Jun 5, 2017 at 9:11 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 14 quoted lines
> On Tue, Jun 06, 2017 at 10:00:12AM +0900, Junio C Hamano wrote:
>> Stefan Beller <sbeller@google.com> writes:
>>
>> > On the subject: maybe we want to rename initial commit
>> > to root commit? (evil-me also thinks we could name it
>> > "parent-less commit", to reinforce what the lovely git man
>> > page generator tries to point at.)
>>
>> Is "initial" harder to understand than "root" or "parent-less"?
>
> I personally think that "Initial commit" is very straightforward.  If we
> get more inquiries about it, we could consider changing it, but seeing
> as this is the first question I've ever seen about it, I think most
> people understand it pretty well.

For what it's worth, I've never quite understood the "Initial commit" message, because the repository is in a state where there are no commits yet, not when HEAD is pointing to a root commit.

Junio C Hamano· Jun 6, 2017, 01:52 UTC · re: Samuel Lijin · lore

Re: What does this output of git supposed to mean ?

Samuel Lijin <sxlijin@gmail.com> writes:
> For what it's worth, I've never quite understood the "Initial commit"
> message, because the repository is in a state where there are no
> commits yet, not when HEAD is pointing to a root commit.

Ah, that is true. The message in the "status" output attempts to tell you that you are about to make the "initial commit", because "status" was not originally a thing (it was just the message when "git commit" gives you while you compose the commit log message).

In the context of "status", it probably is more logically correct if it said "No commit yet" or something. This is no longer "is initial harder than root?" ;-)

David· Jun 6, 2017, 02:06 UTC · re: Junio C Hamano · lore

Re: What does this output of git supposed to mean ?

On 6 June 2017 at 11:52, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Samuel Lijin <sxlijin@gmail.com> writes:
>
>> For what it's worth, I've never quite understood the "Initial commit"
>> message, because the repository is in a state where there are no
>> commits yet, not when HEAD is pointing to a root commit.
>
> In the context of "status", it probably is more logically correct if
> it said "No commit yet" or something.  This is no longer "is initial
> harder than root?" ;-)

Exactly. I agree with OP, in the context of running 'git status', I find the string "Initial commit" confusing in the example below, because at that time no commits exist. This creates confusion what git is talking about. The 'git log' message is not very friendly either.

Perhaps say something like "Repository is empty." there.

$ mkdir test $ cd test $ git init Initialized empty Git repository in /mnt/hart/home/david_d08/junk/test/.git/ $ git log fatal: bad default revision 'HEAD' $ git status On branch master

Initial commit
nothing to commit (create/copy files and use "git add" to track)
Philip Oakley· Jun 6, 2017, 11:07 UTC · re: David · lore

Re: What does this output of git supposed to mean ?

From: "David" <bouncingcats@gmail.com>
Show 17 quoted lines
> On 6 June 2017 at 11:52, Junio C Hamano <gitster@pobox.com> wrote:
>> Samuel Lijin <sxlijin@gmail.com> writes:
>>
>>> For what it's worth, I've never quite understood the "Initial commit"
>>> message, because the repository is in a state where there are no
>>> commits yet, not when HEAD is pointing to a root commit.
>>
>> In the context of "status", it probably is more logically correct if
>> it said "No commit yet" or something.  This is no longer "is initial
>> harder than root?" ;-)
>
> Exactly. I agree with OP, in the context of running 'git status', I find
> the string "Initial commit" confusing in the example below, because
> at that time no commits exist. This creates confusion what git is
> talking about. The 'git log' message is not very friendly either.
>
> Perhaps say something like "Repository is empty." there.

<bikeshed> I like that. I think that is a very appropriately descriptive statement.

An alternative ,with slightly less textual change, could be "Waiting for initial commit" </bikeshed>

Show 14 quoted lines
>
> $ mkdir test
> $ cd test
> $ git init
> Initialized empty Git repository in 
> /mnt/hart/home/david_d08/junk/test/.git/
> $ git log
> fatal: bad default revision 'HEAD'
> $ git status
> On branch master
>
> Initial commit
>
> nothing to commit (create/copy files and use "git add" to track) 
SZEDER Gábor· Jun 6, 2017, 11:43 UTC · re: Philip Oakley · lore

Re: What does this output of git supposed to mean ?

Show 17 quoted lines
> >> In the context of "status", it probably is more logically correct if
> >> it said "No commit yet" or something.  This is no longer "is initial
> >> harder than root?" ;-)
> >
> > Exactly. I agree with OP, in the context of running 'git status', I find
> > the string "Initial commit" confusing in the example below, because
> > at that time no commits exist. This creates confusion what git is
> > talking about. The 'git log' message is not very friendly either.
> >
> > Perhaps say something like "Repository is empty." there.
> 
> <bikeshed>
> I like that. I think that is a very appropriately descriptive statement.
> 
> An alternative ,with slightly less textual change, could be "Waiting for 
> initial commit"
> </bikeshed>
We should consider orphan/unborn branches, too:
  git (master)$ git checkout --orphan newroot
  Switched to a new branch 'newroot'
  git (newroot +)$ git reset --hard
  git (newroot #)$ git status
  On branch newroot
  
  Initial commit
  
  nothing to commit (create/copy files and use "git add" to track)

A purely textual change will not be sufficient, I'm afraid. Saying "Repository is empty" right after 'git init' is fine, I like it. However, on an unborn branch with empty index it would be just wrong.

"Waiting for initial commit" is much better even in this case, but I still don't like that "initial", though I can't say why, and don't have any better suggestion either. Though users experienced enough to create an empty unborn branch would probably not be confused by that.

Jeff King· Jun 6, 2017, 18:42 UTC · re: SZEDER Gábor · lore

Re: What does this output of git supposed to mean ?

On Tue, Jun 06, 2017 at 01:43:55PM +0200, SZEDER Gábor wrote:
Show 24 quoted lines
> > An alternative ,with slightly less textual change, could be "Waiting for 
> > initial commit"
> > </bikeshed>
> 
> We should consider orphan/unborn branches, too:
> 
>   git (master)$ git checkout --orphan newroot
>   Switched to a new branch 'newroot'
>   git (newroot +)$ git reset --hard
>   git (newroot #)$ git status
>   On branch newroot
>   
>   Initial commit
>   
>   nothing to commit (create/copy files and use "git add" to track)
> 
> A purely textual change will not be sufficient, I'm afraid.  Saying
> "Repository is empty" right after 'git init' is fine, I like it.
> However, on an unborn branch with empty index it would be just wrong.
> 
> "Waiting for initial commit" is much better even in this case, but I
> still don't like that "initial", though I can't say why, and don't
> have any better suggestion either.  Though users experienced enough to
> create an empty unborn branch would probably not be confused by that.

I agree. If the state we are describing is limited to the current branch, how about saying so? Like "Your current branch has no commits".

-Peff
Jeff King· Jun 6, 2017, 18:53 UTC · re: Jeff King · lore

Re: What does this output of git supposed to mean ?

On Tue, Jun 06, 2017 at 02:42:01PM -0400, Jeff King wrote:
Show 7 quoted lines
> > "Waiting for initial commit" is much better even in this case, but I
> > still don't like that "initial", though I can't say why, and don't
> > have any better suggestion either.  Though users experienced enough to
> > create an empty unborn branch would probably not be confused by that.
> 
> I agree. If the state we are describing is limited to the current
> branch, how about saying so? Like "Your current branch has no commits".

Actually, something like "does not yet have any commits" might be better.

There is a slight complication, though. There's similar text in "git status -sb", which shows:

  ## Initial commit on master

Should that also change to use consistent terminology? If so, we need a phrasing short phrasing that matches (and the --porcelain and --porcelain=v2 formats of course would need to remain the same).

-Peff
Junio C Hamano· Jun 6, 2017, 11:52 UTC · re: Philip Oakley · lore

Re: What does this output of git supposed to mean ?

"Philip Oakley" <philipoakley@iee.org> writes:
Show 10 quoted lines
> From: "David" <bouncingcats@gmail.com>
>
>> Perhaps say something like "Repository is empty." there.
>
> <bikeshed>
> I like that. I think that is a very appropriately descriptive statement.
>
> An alternative ,with slightly less textual change, could be "Waiting
> for initial commit"
> </bikeshed>
I can buy that one.  

I do not want to see "Repository is empty", as that will open us up to criticism that we are being sloppy and technically incorrect to cater to newbies (i.e. we will give the message if you do "checkout --orphan", and repository is definitely not empty in that case).

"Waiting for the initial commit", or "No commits yet", can be explained to describe the state of the current branch (not the state of the repository), and it is correct that we do not have any commit on the branch, and the branch is waiting for the initial commit.

Kaartic Sivaraam· Jun 6, 2017, 14:08 UTC · re: Junio C Hamano · lore

Re: What does this output of git supposed to mean ?

On Tue, 2017-06-06 at 20:52 +0900, Junio C Hamano wrote:
Show 5 quoted lines
> "Waiting for the initial commit", or "No commits yet", can be
> explained to describe the state of the current branch (not the state
> of the repository), and it is correct that we do not have any commit
> on the branch, and the branch is waiting for the initial commit.
> 

Looks descriptive to me too. Just for the note, I wouldn't have asked this question if `git status` showed a message like this.

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Philip Oakley· Jun 6, 2017, 22:05 UTC · re: Kaartic Sivaraam · lore

Re: What does this output of git supposed to mean ?

From: "Kaartic Sivaraam" <kaarticsivaraam91196@gmail.com>
Show 9 quoted lines
> On Tue, 2017-06-06 at 20:52 +0900, Junio C Hamano wrote:
>> "Waiting for the initial commit", or "No commits yet", can be
>> explained to describe the state of the current branch (not the state
>> of the repository), and it is correct that we do not have any commit
>> on the branch, and the branch is waiting for the initial commit.
>>
> Looks descriptive to me too. Just for the note, I wouldn't have asked
> this question if `git status` showed a message like this.
>

Maybe have a try at a patch to update the text? See the git/Documentation/SubmittingPatches for guidance.

> -- 
> Regards,
> Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> 
Kaartic Sivaraam· Jun 7, 2017, 12:56 UTC · re: Philip Oakley · lore

Re: What does this output of git supposed to mean ?

On Wednesday 07 June 2017 03:35 AM, Philip Oakley wrote:
> Maybe have a try at a patch to update the text? See the 
> git/Documentation/SubmittingPatches for guidance.

I guess this should be trivial (correct me if I'm wrong). I'll try when I find time. In case I make the change which of the following message should replace the message 'Initial commit' ? (this could be a poll, I guess)

1. No commit yet
2. Waiting for initial commit
3. Your current branch does not have any commits
Further what is to be done about the following comment,
On Wednesday 07 June 2017 12:23 AM, Jeff King wrote:

There is a slight complication, though. There's similar text in "git status -sb", which shows: ## Initial commit on master Should that also change to use consistent terminology? If so, we need a phrasing short phrasing that matches (and the --porcelain and --porcelain=v2 formats of course would need to remain the same).

BTW, could anyone provide a pointer to the implementation that prints this message ?

-- Regards, Kaartic Sivaraam

Philip Oakley· Jun 7, 2017, 22:14 UTC · re: Kaartic Sivaraam · lore

Re: What does this output of git supposed to mean ?

From: "Kaartic Sivaraam" <kaarticsivaraam91196@gmail.com>
Show 10 quoted lines
> On Wednesday 07 June 2017 03:35 AM, Philip Oakley wrote:
>> Maybe have a try at a patch to update the text? See the 
>> git/Documentation/SubmittingPatches for guidance.
> I guess this should be trivial (correct me if I'm wrong). I'll try when I 
> find time. In case I make the change which of the following message should 
> replace the message 'Initial commit' ? (this could be a poll, I guess)
>
> 1. No commit yet
> 2. Waiting for initial commit
> 3. Your current branch does not have any commits

2, or 3, or a mix of the two "current branch waiting for initial commit" maybe.

Show 13 quoted lines
>
> Further what is to be done about the following comment,
>
> On Wednesday 07 June 2017 12:23 AM, Jeff King wrote:
>
> There is a slight complication, though. There's similar text in "git 
> status -sb", which shows: ## Initial commit on master Should that also 
> change to use consistent terminology? If so, we need a phrasing short 
> phrasing that matches (and the --porcelain and --porcelain=v2 formats of 
> course would need to remain the same).
>
> BTW, could anyone provide a pointer to the implementation that prints this 
> message ?

I think the two messages are in wt-status.c with the simple "Initial commit" at ~L1560, while ~L1728 has the "Initial commit on" line.

Philip
>
> --
> Regards,
> Kaartic Sivaraam 

← back to recent threads