In Git, I sometimes work on long-running branches. I like to rebase on master from time to time to make merging easier when I’m ready.
After rebasing, I can’t push a previously-pushed branch to a remote, because my branch’s history no longer agrees with the remote’s history of that branch. So I have to delete it first.
This is my current workflow:
git checkout my_branch
git rebase master
git push origin :my_branch # Delete remote version of the branch
git push origin my_branch # Push up my new version of history on this branch
Is there a single, atomic command that could replace the last two commands?
If you are allowed to rewrite the remote branch, you can use
git push --force my_remote my_branch.