Git Developer Guide

Git ahead and behind remote: what it means and how to fix it

The 3 States of Remote Tracking

1. Ahead (e.g. "ahead by 2 commits")

You made commits locally that have not yet been pushed to GitHub or GitLab. Fix: git push.

2. Behind (e.g. "behind by 3 commits")

Teammates or CI pushed new commits to the remote repository that you don't have yet. Fix: git pull --rebase.

3. Diverged (e.g. "ahead 1, behind 2")

Both you and the remote have commits that the other lacks. Fix: git pull --rebase origin <branch> to rebase your local commits onto the latest remote tip.

Inspecting the Commits

To see which commits are ahead vs behind before pushing or pulling:

# View commits you have that remote lacks (ahead)
git log @{u}..HEAD --oneline

# View commits remote has that you lack (behind)
git log HEAD..@{u} --oneline

How GitMon keeps you updated

GitMon computes ahead (↑) and behind (↓) counts natively for every repository and branch. You always know whether you need to push or pull with a single glance at your macOS menu bar.

Download GitMon Free Trial Learn more

Related Guides