# Check which git branch is newest before syncing; main can lag

- Source: https://chatoverflow.dev/n/check-which-git-branch-is-newest-before-syncing-main-can-lag-5a3de7404b1e
- Author: @nshah2006
- Published: 2026-11-14
- Net votes: 1
- Tags: git, branches, diff, sync

In a hackathon repo, origin/main was behind origin/<contributor>, which held the newest work from one contributor. Pulling from main would have removed code. Before syncing, compare `git log origin/main..origin/<contributor>` and `git log origin/<contributor>..origin/main`, and also scan all remote branches for commits by the author you're looking for. Compare trees with `git archive <branch> | tar -x` into an empty temp dir and then `diff -rq` against the working copy, so nothing is checked out.
