git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git add documentation error

From
ABAngelo Borsotti <angelo.borsotti@gmail.com>
Date
Oct 27, 2022, 16:57 UTC
Message-ID
<CAB9Jk9DPdVmmb2DPDKPm5FLGr-XJa5kNouCYmcjh534Y2z1rVQ@mail.gmail.com>
In-Reply-To
<2ed22fa1-4d9d-e50a-18cf-048007272729@iee.email>
Hi Philip.
I have git 2.38.0.windows.1 on  windows 10.
I have then changed again C2.java, and made only one git add, and a commit
     > git add C2.java
     > git commit -m "commit2"
     [master 8ec0c2f] commit2
     1 file changed, 1 insertion(+), 1 deletion(-)

Then I displayed the contents of both commits, and seen that it is pretty much the same:

D:\gittest>git show --pretty="" --name-only 91ef45d C2.java

D:\gittest>git show --pretty="" --name-only 8ec0c2f C2.java

If there is any difference in the files, probably it is under the hood.
-Angelo
On Thu, 27 Oct 2022 at 18:16, Philip Oakley <philipoakley@iee.email> wrote:
Show 75 quoted lines
>
> Hi Angelo, please use 'reply all' so others can participate.
> Also, in-line replies are preferred.
>
> On 27/10/2022 16:28, Angelo Borsotti wrote:
> > Hi,
> >
> > I have tested this in the following way: I have two files: C1.java and C2.java
> >
> >     > git status
> >     On branch master
> >     nothing added to commit
> >     > ... edit C2.java
> >     > git status
> >     On branch master
> >     Changes not staged for commit:
> >     (use "git add <file>..." to update what will be committed)
> >     (use "git restore <file>..." to discard changes in working directory)
> >         modified:   C2.java
> >      > git add C1.java
> >      > git add C2.java
> >      > git commit -m "commit2"
> >      D:\gittest>git commit -m "commit1"
> >      [master 91ef45d] commit1
> >      1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > In commit1 there is only one file, which is C2.java.
>
> It does say "1 file changed", which is true.
> What it fails to mention is all the other files that are included within
> the commit, but are unchanged.
>
> Maybe have a look at
> https://git-scm.com/docs/git-ls-tree#Documentation/git-ls-tree.txt---name-status,
> probably with the -r option (check the command's description)
>
> What Git version & OS are you on?
> > This is a useful feature: one can stage all its files without
> > bothering to remember
> > which one had been changed, and then make a commit, and place the commands
> > to do it in a script to be used each time a new commit is needed.
> >
> > -Angelo
> >     ...
> >
> > On Thu, 27 Oct 2022 at 17:10, Philip Oakley <philipoakley@iee.email> wrote:
> >> Hi,
> >> On 27/10/2022 12:53, Angelo Borsotti wrote:
> >>> Hello,
> >>>
> >>> the reference manual for the "git add" command does not
> >>> specify what that command does when applied to an
> >>> unmodified file.
> >> I presume that this file is already tracked..
> >>> By testing this, I have seen that it does not add the file
> >>> to the index,
> >> How was this tested?
> >>
> >> If you have no changes, thaen the status diff will have no mention of
> >> that file.
> >> Perhaps change the tracked mode bits to see if that is noticed (note
> >> though, not all mode bits are tracked..)
> >>> and consequently it does not add it when a
> >>> subsequent commit is done.
> >> I suspect this is a subtle mental model misunderstanding about the
> >> distinction between a commit as a snapshot, and a commit being reported
> >> as the diff relative to its parent (and here, there is none, if the file
> >> is unmodified)
> >>> I think that this should be documented.
> >> A test script with sample output would help here.
> >> --
> >> Philip
> >>
> >>
>
Previous: Philip OakleyNext: Junio C Hamano
Message 4 of 8 in “Git add documentation error”
  1. Angelo BorsottiOct 27, 2022
  2. Philip OakleyOct 27, 2022
  3. Philip OakleyOct 27, 2022
  4. Angelo BorsottiOct 27, 2022
  5. Junio C HamanoOct 27, 2022
  6. Angelo BorsottiOct 27, 2022
  7. Junio C HamanoOct 27, 2022
  8. Angelo BorsottiOct 27, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.