# git clone --shallow-since: Time-Bounded History

> git clone/fetch --shallow-since limits history to commits after a date, an alternative to --depth for CI. Reference for the flag, --shallow-exclude, and errors.

Source: https://latchkey.dev/learn/command-reference/git-shallow-since  
Updated: 2026-06-30

git clone --shallow-since=<date> fetches only commits newer than that date, useful when you need recent history of unknown depth rather than a fixed --depth count.

A fixed --depth is a guess; --shallow-since bounds history by time instead, so you get every commit in the last week or since a release tag without overshooting. It pairs with --shallow-exclude to stop at a ref.

## What it does

git clone --shallow-since=<date> creates a shallow clone containing commits committed after <date>. --shallow-exclude=<ref> instead truncates history at a given tag or ref. Both are alternatives to --depth that express "how much history" in terms the build actually cares about.

## Common usage

```Terminal
git clone --shallow-since="2 weeks ago" https://github.com/org/repo
git clone --shallow-since="2026-06-01" https://github.com/org/repo
# stop history at the previous release tag
git clone --shallow-exclude=v1.4.0 https://github.com/org/repo
# deepen an existing shallow clone by date
git fetch --shallow-since="1 month ago"
```

## Options

| Flag | What it does |
| --- | --- |
| --shallow-since=<date> | Include only commits after this date |
| --shallow-exclude=<ref> | Truncate history at this ref/tag |
| --depth <n> | Alternative: fixed number of commits |
| --unshallow | Convert a shallow clone to a full one |
| --no-single-branch | Fetch all branches within the shallow window |

## In CI

Use --shallow-since when a step (changelog, diff against last release) needs "since X" history but not the whole repo. The server must support the protocol; older or proxied Git servers may refuse and you fall back to --depth. A clone too shallow for git describe or git merge-base will error later; deepen or --unshallow if so.

## Common errors in CI

"fatal: the remote end hung up unexpectedly" or "Server does not support --shallow-since" means the host or protocol version cannot honor it; use --depth. "fatal: no commits selected for shallow requests" means the date excluded the branch tip entirely (date in the future or wrong format).

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git clone --shallow-since: Time-Bounded History?

A fixed --depth is a guess; --shallow-since bounds history by time instead, so you get every commit in the last week or since a release tag without overshooting. It pairs with --shallow-exclude to stop at a ref.

### What it does?

git clone --shallow-since=<date> creates a shallow clone containing commits committed after <date>. --shallow-exclude=<ref> instead truncates history at a given tag or ref. Both are alternatives to --depth that express "how much history" in terms the build actually cares about.

### In CI?

Use --shallow-since when a step (changelog, diff against last release) needs "since X" history but not the whole repo. The server must support the protocol; older or proxied Git servers may refuse and you fall back to --depth. A clone too shallow for git describe or git merge-base will error later; deepen or --unshallow if so.

### Common errors in CI?

"fatal: the remote end hung up unexpectedly" or "Server does not support --shallow-since" means the host or protocol version cannot honor it; use --depth. "fatal: no commits selected for shallow requests" means the date excluded the branch tip entirely (date in the future or wrong format).

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
