Skip to content

Instantly share code, notes, and snippets.

Created Nov 16, 2021
What would you like to do?
So you've committed to main, but your main is behind origin main and the push gets rejected...
➜ git commit -am "my commit to main"
[main 10bc4d8] my commit to main
1 file changed, 11 deletions(-)
➜ git push
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to ''
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
➜ git checkout -b blah
➜ git checkout main && git reset --hard origin/main && git pull && git checkout blah && git rebase main && git checkout main && git merge blah && git branch -d blah
➜ git push
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 444 bytes | 444.00 KiB/s, done.
Total 5 (delta 4), reused 1 (delta 1), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
6fbfb47..87a0639 main -> main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment