Can I destroy and recreate a remote Git branch in one command?

In Git, I sometimes work on long branches. I like to relearn the wizard from time to time to make it easier to merge when I'm ready.

After rebooting, I can not push the previously deleted branch to the remote computer, because my branch history is no longer consistent with the deleted history of this branch. So first I have to delete it.

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 one atomic command that could replace the last two teams?

+6
source share
1 answer

If you are allowed to rewrite the remote branch, you can use git push --force my_remote my_branch .

+10
source

Source: https://habr.com/ru/post/917190/


All Articles