# Find The Date That A File Was Added To The Repo

The `git log` command has a bunch of flags that you can use to filter commits and format their output.

We can get `git log` to only show the date for a commit in the `short` format with the following flags:

```bash
$ git log --pretty=format:"%ad" --date=short
```

We can also get `git log` to filter commits to just those that have files being added:

```bash
$ git log --diff-filter=A
```

Like many `git` commands, we can restrict the output to those that match a path or file.

```bash
$ git log -- README.md
```

If we put all of these together, then we have a one-line command for getting the date a specific file was added to the repository:

```bash
$ git log --pretty=format:"%ad" --date=short --diff-filter=A -- README.md
2015-02-06
```

See `man git-log` for more details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/tools/git/find-the-date-that-a-file-was-added-to-the-repo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
