>From what I have observed, the answer to your question is "Yes." However, a
"git add" also changes the index.

A transcript (on a Fedora 22 x86_64 system) which may help:

$mkdir temp
joarmc@mckown5 2015-10-24T19:44:47 ~/junk
$cd temp
joarmc@mckown5 2015-10-24T19:44:51 ~/junk/temp
$git init
Initialized empty Git repository in /home/joarmc/junk/temp/.git/
joarmc@mckown5 2015-10-24T19:45:00 ~/junk/temp
$echo "a" >x
joarmc@mckown5 2015-10-24T19:45:09 ~/junk/temp
$ls -l .git/index
ls: cannot access .git/index: No such file or directory
joarmc@mckown5 2015-10-24T19:45:15 ~/junk/temp
$git add x
joarmc@mckown5 2015-10-24T19:45:20 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 96 Oct 24 19:45 .git/index
joarmc@mckown5 2015-10-24T19:45:22 ~/junk/temp
$sha1sum .git/index
530c44247e959d548d5013d8ebc83991ed3e7057  .git/index
joarmc@mckown5 2015-10-24T19:45:30 ~/junk/temp
$echo "b">>x
joarmc@mckown5 2015-10-24T19:45:37 ~/junk/temp
$git add x
joarmc@mckown5 2015-10-24T19:45:42 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 96 Oct 24 19:45 .git/index
joarmc@mckown5 2015-10-24T19:45:49 ~/junk/temp
$sha1sum .git/index
96388bdb4c2180bf32cd141dc5df6c81a33e8aec  .git/index
joarmc@mckown5 2015-10-24T19:45:58 ~/junk/temp
$git commit -m 'some comment'
[master (root-commit) 4b1dfae] some comment
1 file changed, 2 insertions(+)
create mode 100644 x
joarmc@mckown5 2015-10-24T19:46:05 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 129 Oct 24 19:46 .git/index
joarmc@mckown5 2015-10-24T19:50:31 ~/junk/temp
$sha1sum .git/index
6e853ffa930651333200dc55c1610bb5ae26db25  .git/index
joarmc@mckown5 2015-10-24T19:46:08 ~/junk/temp


Note that .git/index changes after the "git add x" each time. It also
changes after the "git commit"



On Sat, Oct 24, 2015 at 7:29 PM, ozzloy <ozz...@gmail.com> wrote:

> does `git commit` modify $GIT_DIR/index?
> i just diffed index from before and after a commit and found no
> difference.  i'm guessing this is reliable behavior, but i wanted to
> make sure.  it seems like the idea of index is that it's always ready
> and waiting to be turned into the next commit.  so commits wouldn't ever
> modify it.
>
> i'm writing a script that depends on this behavior and i want to make
> sure i have the concepts right.
>
> i searched online but found mostly posts telling me higher level stuff,
> like that "you have to add to the staging area before committing".  i also
> searched the archives for this mailing list, but there's a _lot_ to go
> through.  sorry if this is a repeat.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to