Skip to contentSkip to conversation

What does this output of git supposed to mean ?

DISCUSSION Kaartic Sivaraam 9 participants 17 messages Jun 5, 2017 – Jun 7, 2017

lore
Share & tools
lore
#0 lore raw

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,

Quoted 5 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?

Signature · 2 lines
Regards,
Kaartic Sivaraam <[email protected]>
#1 lore raw
Quoted 5 lines · Kaartic Sivaraam

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,

Quoted 8 lines
Quoted 5 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?

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.

Signature · 3 lines
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
#2 lore raw
Quoted 13 lines · brian m. carlson
Quoted 12 lines · Kaartic Sivaraam

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,

Quoted 5 lines

On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

Quoted 6 lines
Quoted 1 line

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.)

#3 lore raw
Quoted 4 lines · Stefan Beller

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"?

#4 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Stefan Beller

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.

Signature · 3 lines
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
#5 lore raw
Quoted 8 lines · brian m. carlson
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Stefan Beller

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.)

Quoted 6 lines
Quoted 1 line

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.

#6 lore raw
Quoted 3 lines · Samuel Lijin

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?" ;-)

#7 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Samuel Lijin

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)

#8 lore raw

From: "David" <[email protected]>

Quoted 11 lines · Junio C Hamano
Quoted 9 lines
Quoted 3 lines · Samuel Lijin

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?" ;-)

Quoted 6 lines

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>

Quoted 13 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)

#9 lore raw
Quoted 10 lines
Quoted 10 lines
Quoted 4 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.

Quoted 8 lines
Quoted 1 line

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.

#10 lore raw
Quoted 16 lines · SZEDER Gábor
Quoted 3 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)

Quoted 8 lines

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

#11 lore raw
Quoted 7 lines · Jeff King
Quoted 4 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

#12 lore raw
In reply to Philip Oakley
Quoted 10 lines · Philip Oakley

From: "David" <[email protected]>

Quoted 1 line

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.

#13 lore raw
Quoted 5 lines · Junio C Hamano

"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.

Signature · 2 lines
Regards,
Kaartic Sivaraam <[email protected]>
#14 lore raw

From: "Kaartic Sivaraam" <[email protected]>

Quoted 9 lines · Junio C Hamano
Quoted 5 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.

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

Quoted 3 lines
Signature · 2 lines
Regards,
Kaartic Sivaraam <[email protected]> 
#15 lore raw
Quoted 1 line · Philip Oakley

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

#16 lore raw

From: "Kaartic Sivaraam" <[email protected]>

Quoted 7 lines · Philip Oakley
Quoted 1 line

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.

Quoted 8 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

Quoted 4 lines

--
Regards,
Kaartic Sivaraam