# How git detects changes during commit?

3 messages from 2010-10-27 to 2010-10-28. Participants: longphant, Jonathan Nieder.
Thread: https://gitlist.dev/t/25565

## longphant, 2010-10-27 20:36

Subject: How git detects changes during commit?
Message-ID: <1288211811436-5680208.post@n2.nabble.com>
URL: https://gitlist.dev/e/1288211811436-5680208.post%40n2.nabble.com

```

Say you check out a directory of 100 files. You edit 5 of the files, and you
go to commit the directory back. How does git know which of the 100 files
were modified (not all of them were)?
-- 
View this message in context: http://git.661346.n2.nabble.com/How-git-detects-changes-during-commit-tp5680208p5680208.html
Sent from the git mailing list archive at Nabble.com.

```

## Jonathan Nieder, 2010-10-27 20:54

Subject: Re: How git detects changes during commit?
Message-ID: <20101027205441.GA8242@burratino>
URL: https://gitlist.dev/e/20101027205441.GA8242%40burratino
In-Reply-To: <1288211811436-5680208.post@n2.nabble.com>

```
Hi,

longphant wrote:

> Say you check out a directory of 100 files. You edit 5 of the files, and you
> go to commit the directory back. How does git know which of the 100 files
> were modified (not all of them were)?

The lstat system call.  See the git-update-index(1) manual for some
hints (since most high-level commands do the equivalent of
"git update-index --refresh -q" before working with the work tree).

Hope that helps,
Jonathan

```

## longphant, 2010-10-28 17:23

Subject: Re: How git detects changes during commit?
Message-ID: <1288286637497-5683536.post@n2.nabble.com>
URL: https://gitlist.dev/e/1288286637497-5683536.post%40n2.nabble.com
In-Reply-To: <20101027205441.GA8242@burratino>

```

Thanks, that is a lot of help. I am a complete noob to version control, so I
was wondering if you could give me a noobie tutorial of how it works. Does
git lstat each file that is committed and then check the time of last
modification? Or does it lstat the directory?
-- 
View this message in context: http://git.661346.n2.nabble.com/How-git-detects-changes-during-commit-tp5680208p5683536.html
Sent from the git mailing list archive at Nabble.com.

```
