Skip to content
LatchkeyLatchkey home

git pull: Usage, Options & Common CI Errors

git pull is git fetch followed by an integration step (merge or rebase).

Pull updates your branch with remote changes. In CI you almost always want --rebase or --ff-only for predictable results.

What it does

git pull runs git fetch to get new commits, then merges (default) or rebases them onto your current branch.

Common usage

Terminal
git pull
git pull --rebase origin main
git pull --ff-only             # fail instead of creating a merge

Options

FlagWhat it does
--rebaseRebase local commits instead of merging
--ff-onlyOnly fast-forward; error if a merge is required
--no-rebaseForce a merge integration
--autostashStash/unstash dirty changes around the pull

Common errors in CI

fatal: Need to specify how to reconcile divergent branches - newer Git refuses to guess. Pick one: git config pull.rebase true (or pull.ff only). "Your local changes would be overwritten by merge" means a dirty tree; commit, stash, or use --autostash first.

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

Frequently asked questions

git pull: Usage, Options & Common CI Errors?
Pull updates your branch with remote changes. In CI you almost always want --rebase or --ff-only for predictable results.
What it does?
git pull runs git fetch to get new commits, then merges (default) or rebases them onto your current branch.
Common errors in CI?
fatal: Need to specify how to reconcile divergent branches - newer Git refuses to guess. Pick one: git config pull.rebase true (or pull.ff only). "Your local changes would be overwritten by merge" means a dirty tree; commit, stash, or use --autostash first.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card