I often rebase feature branches and then want to force push them to the server.
git push --force origin feature-mongodb-support
Is there any shortcut for git push --force origin <current branch>
?
You can use aliases to shorten the command. Use it like this:
git config --global alias.fpush "push --force origin"
Now to push your branch just type:
git fpush feature-mongodb-support
Or you can even hardcode the branch name into the command:
git alias fpush "push --force origin feature-mongodb-support"
and use only git fpush
to push your precious work into the upstream.
However, non-fast-forward updates are dangerous since you will basically overwrite all the history on server that occurred between the last merge/rebase into your local branch and the forced push. If you need to do them often there is definitely something wrong in your workflow.