# Git "warning: redirecting to https://..." in CI

> Fix Git "warning: redirecting to https://.../" in CI - an http:// or trailing-slash-less remote URL the host 301-redirects, which can break credential reuse or push.

Source: https://latchkey.dev/learn/git/git-redirecting-to-https-warning  
Updated: 2026-06-25

The host answered your request with a redirect to a different URL - usually `http://` to `https://`, or a normalized path. The clone may still work, but the redirect can drop credentials or break a push, so the warning is worth fixing at the source.

## Diagnose it: depth, refs, or credentials?

CI checkouts are shallow and detached by default, which breaks anything that needs history or a branch name. Before treating it as a credential problem, confirm what the runner actually fetched.

```.github/workflows/ci.yml
- run: |
    git rev-parse --is-shallow-repository
    git rev-parse --abbrev-ref HEAD      # prints HEAD when detached
    git log --oneline -3
    git remote -v
    git for-each-ref --format="%(refname)" | head
```

> `actions/checkout` fetches depth 1 and leaves you on a detached HEAD. Anything diffing against a base ref, reading the branch name, or running `git describe` needs `fetch-depth: 0` and usually an explicit ref.

## The checkout options that fix most of this

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0        # full history: diffs, tags, git describe
    submodules: recursive # submodules are NOT fetched by default
    persist-credentials: false  # if a later step pushes with its own token
```

## FAQ

### What causes Git "warning: redirecting to https://..." in CI?

There are 2 common causes: remote configured with http:// or a non-canonical path and credentials not reused across the redirect. An http:// remote (or one missing the trailing .git) is 301-redirected by the host to the canonical https://...git/.

### How do I fix Git "warning: redirecting to https://..." in CI?

There are 2 fixes depending on which cause you have: point the remote at the canonical https url and allow credential reuse on redirect if you must redirect. Work through them in order, since the first is the most common.

### What does Git "warning: redirecting to https://..." in CI actually mean?

Git prints warning: redirecting to https://github.com/org/repo.git/ during a fetch or push.

### How do I stop Git "warning: redirecting to https://..." in CI happening again?

Always configure remotes with the canonical https://host/org/repo.git URL. The prevention section lists 3 changes that keep it from recurring.

---

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
