

No need to panic! If you are very lucky someone else who is working on the same code pulled a recent version of the branch just before you broke it. You are without a doubt a responsible developer but I bet it happened to you at least once, that you or one of your teammates accidentally ran git push -force into an important branch that should never be messed with and Oops! In the blink of an eye, everybody’s latest work is now lost.
#GIT REBASE FAST FORWARD HOW TO#
Guide: How to deal with destructive -force It’s the same force but with a life vest. force-with-lease gives you the flexibility to override new commits on your remote branch whilst protecting your old commit history. Pretty great right? It becomes even better(!!) you can specify - force-with-lease exactly which commit, branch or ref to compare to.

#GIT REBASE FAST FORWARD UPDATE#
On default, -force-with-lease will refuse to update branch unless the remote-tracking branch and the remote branch points to the same commit ref.

The -force option has a not so famous relative called - force-with-lease, which enables us to push -force our changes with a guarantee that we won’t overwrite somebody else’s changes. Shame on you Bob! Alternative: push - force-with-lease you must wonder why? Well… force pushes the changes with no regard to the state of the tracked branch, therefore commits might get lost in the process. One of the common mistakes using this command is when Bob forgets to update (git pull) his local tracked branch, in this case, using the force might cause Bob a lot of trouble. If there is an ancestor commit that exists in the remote and not in local(i.e someone updated the remote and we are not up to date) Git won’t be able to find a linear path between the commits and git push will fail. When our changes are pushed Git automatically searches for a linear path from the current ref to the target commit ref.
