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>
?
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>
?
After reading these answers and reading this answer to a related question (https://stackoverflow.com/a/18782415/586), I created this alias to force push to
origin
based on the current branch name:If you use oh my zsh you can simply do
which will do this for you
https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet
This should do the trick:
Which will let you use
git fpush
as a shorter alternative.To automatically force-push to the branch that is tracked (regardless of its name and upstream), I've devised this alias:
(line is broken for readability)
(based on another SO answer)
You can use aliases to shorten the command. Use it like this:
Now to push your branch just type:
Or you can even hardcode the branch name into the command:
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.