GIT Push safely using --force-with-lease
In git, rebase is a nice way to preserve a clear history. There is an issue that after rebasing your push will get rejected from the server as you will have changed history. There is a dangerous way to use switch -f
, forcing the push to override the server code. However, another switch is safer to use --force-with-lease
. This variant of push will only succeed if the HEAD is the same on the server as locally.
So for safe pushing (e.g. after rebase) use: git push --force-with-lease
.