Achraf
Achraf

Reputation: 357

replace the remote branch with the local one

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

Upvotes: 5

Views: 5675

Answers (1)

janos
janos

Reputation: 124646

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 

Upvotes: 5

Related Questions