# last commit in a directory

3 messages from 2011-01-25 to 2011-01-25. Participants: Leonid Podolny, Johannes Sixt.
Thread: https://gitlist.dev/t/26332

## Leonid Podolny, 2011-01-25 08:29

Subject: last commit in a directory
Message-ID: <4D3E89FA.4080901@gmail.com>
URL: https://gitlist.dev/e/4D3E89FA.4080901%40gmail.com

```
Hi,
I have a really simple question: how do I find a last commit for the given directory inside the repository? I want to avoid rebuilding the specific part of the project if there were no changes in it since the last build, so I need to find the sha of the last time the directory was changed.
  Thanks, L.

```

## Johannes Sixt, 2011-01-25 08:47

Subject: Re: last commit in a directory
Message-ID: <4D3E8E0B.2090200@viscovery.net>
URL: https://gitlist.dev/e/4D3E8E0B.2090200%40viscovery.net
In-Reply-To: <4D3E89FA.4080901@gmail.com>

```
Am 1/25/2011 9:29, schrieb Leonid Podolny:
> I have a really simple question: how do I find a last commit for the given
> directory inside the repository?

git log -1 that/directory

But if you need it in a script, this is preferable:

  lastsha1=$(git rev-list -1 HEAD -- "$directory")

-- Hannes

```

## Leonid Podolny, 2011-01-25 08:50

Subject: Re: last commit in a directory
Message-ID: <4D3E8EC7.8000407@gmail.com>
URL: https://gitlist.dev/e/4D3E8EC7.8000407%40gmail.com
In-Reply-To: <4D3E8E0B.2090200@viscovery.net>

```
On 01/25/2011 10:47 AM, Johannes Sixt wrote:
> Am 1/25/2011 9:29, schrieb Leonid Podolny:
>> I have a really simple question: how do I find a last commit for the given
>> directory inside the repository?
>
> git log -1 that/directory
>
> But if you need it in a script, this is preferable:
>
>    lastsha1=$(git rev-list -1 HEAD -- "$directory")
>

Thanks!

```
