rebase snippets

failed to push some refs to

Tagged git, pull, push, rebase  Languages bash

git push fails:

❯ git push
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:xxx/yyy.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Use pull and rebase to rewind and replay your commit, otherwise you will end up with a “merge commit” in your git history:

❯ git pull --rebase
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), done.
   aaa..bbb  master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: <Your commit message>.

How to Undo Almost Anything With Git:

Git Pretty - Git Flowchart:

Oh Shit, Git!?!: