Select Page

git Force Push

David Walsh
Published: August 19, 2022

Rebasing is a frequent task for anyone using git. We sometimes use rebasing to branch our code from the last changes or even just to drop commits from a branch.

Oftentimes when trying to push after a rebase, you’ll see something like the following:

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.

Commonly developers will use the --force or -f flags during a push to force pushing code changes:

git push origin my-branch --force
# or
git push origin my-branch -f

I was recently surprised to find out that you could also prefix the branch name with + to force a push:

git push origin +my-branch

The + syntax is interesting but doesn’t seem intuitive so it’s not a practice I’d use, but that doesn’t mean you shouldn’t!

  • Do / Undo Functionality with MooTools

    We all know that do/undo functionality is a God send for word processing apps. I’ve used those terms so often that I think of JavaScript actions in terms of “do” an “undo.” I’ve put together a proof of concept Do/Undo class with MooTools. The MooTools…

  • Reverse Element Order with CSS Flexbox

    CSS is becoming more and more powerful these days, almost to the point where the order of HTML elements output to the page no longer matters from a display standpoint — CSS lets you do so much that almost any layout, large or small, is possible.  Semantics…