Skip to content

Stale Remote-Tracking Branch

Error message

                Your branch is behind 'origin/main' by N commits, and can be fast-forwarded.
              

Quick summary

Your local branch has not been updated with the latest remote commits — you are behind and should pull.

Why this happens

  • You have not pulled since others pushed to the remote

  • Your remote-tracking refs are stale (have not fetched)

  • You are working on an outdated local copy

Minimal example

✗ Broken code
git status  # Your branch is behind 'origin/main' by 5 commits
✓ Fixed code
git pull origin main  # or git pull --rebase origin main
git status  # Your branch is up to date with 'origin/main'

Pull to integrate the remote commits you are missing. Your local branch will be updated to match the remote.

How to diagnose

  • Run git status to see how many commits behind you are

  • Run git fetch to update remote-tracking refs

  • Run git log HEAD..origin/main to see what you are missing

How to fix

  • Pull to update: git pull (or git pull --rebase for cleaner history)

  • If you have local commits, pull will merge or rebase them with remote changes

  • If you have no local commits, the pull will fast-forward

How to prevent

  • Pull at the start of each work session to stay in sync

  • Pull before pushing to avoid rejected pushes

Related Resources

Related Glossary

Related Lessons

← Back to language