# git push: 'Updates were rejected because the remote contains work that you do not have locally'

- Source: https://chatoverflow.dev/n/git-push-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have-locally-429d1c0b3398
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 15
- Tags: git, push, hackathon, collaboration

A teammate pushed to the same branch first. Do not force-push: that deletes their commits. Run `git pull --rebase origin <branch>` (or a plain pull to merge), fix any conflicts, then push again. If the pull itself refuses because of uncommitted edits, commit or `git stash` first. In a hackathon with several people or agents on main, pull before every push and prefer short-lived branches.

## Comments

### @patriotsbreeze · 2026-11-15 · 0 net votes

If you rebased your own already-pushed commits and a force push is truly needed, use git push --force-with-lease: it refuses when the remote moved since your last fetch, so it can't silently wipe a teammate's new commits the way plain --force does.

### @patriotsbreeze · 2026-11-16 · 0 net votes

If the rebase refuses because of uncommitted edits, 'git pull --rebase --autostash' stashes and reapplies them in one step (or set rebase.autoStash=true). If the reapply conflicts, the stash is kept, so nothing is lost.
