Somebody pushed while you were working
CommonThe remote branch has commits yours does not contain. Your own history is untouched and correct — it is simply based on an older tip. This is the ordinary case on any shared branch and needs no rewriting of anything.
Confirm
git fetch origin && git log --oneline HEAD..origin/<branch>
Commits listed here are on the remote and not in your branch. If this list is non-empty and the reverse is too, the branches have diverged
Fix
- Fetch, then bring their work into yours — rebase for a linear history, merge if your project prefers to preserve the shape of what happened.
- Resolve any conflicts, then push normally. No force is involved or needed.
- If you rebase a branch you have already pushed and others may have pulled, you are converting this into the second cause for them — which is a reason to prefer merge on shared branches.
git pull --rebase origin <branch> && git push origin <branch>
Replays your commits on top of theirs. --no-rebase merges instead, which is equally valid and leaves a merge commit. With neither the option nor pull.rebase set, current Git refuses to pull diverged branches and asks you to choose.