how can I replace a remote branch with the local one. if there is a file in the remote branch that does not exist in the local one then delete it. Replace everything (files, commits). I was going to delete the remote branch, then create it again and applly a push, but I don't know if it's the right way to do it. thanks
If you are absolutely sure that you want the remote branch replaced with a local branch, and the effects of rewriting the history on other collaborators of that branch, you can force push to it from the local branch:
git push remotename localbranch:remotebranch -f
If the local and remote branch name are the same, then the command is even simpler:
git push remotename branch -f
So if your branch name is develop
then the command will be:
git push origin develop -f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With