Re: Git add documentation error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Angelo Borsotti <angelo.borsotti@xxxxxxxxx> writes:

> 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

You did not display the contents of these commits, though.  For each
of these commits, you checked the _difference_ between it and its
parent.

In the previous sequence

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

91ef45d, relative to its parent (i.e. the previous state before the
commit was made), C2.java was modified.  C1.java was not.

So, what you saw

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

is very much consistent with what you did.  And the above does not
mean 91ef45d does not have C1.java.  If you want to "display" the
contents of commit 91ef45d, you could

	$ git ls-tree -r --name-only 91ef45d

which lists all the contents in commit 91ef45d

or

	$ git diff --name-only $(git hash-object --stdin -t tree </dev/null) 91ef45d

which compares all the contents in commit 91ef45d with a completely
empty tree.

In them, you'd see both C1 and C2, among other things that you did
not modify in 91ef45d.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux