Logo Questions Linux Laravel Mysql Ubuntu Git Menu

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

like image 317
Achraf Avatar asked Aug 11 '17 10:08


1 Answers

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 
like image 73
janos Avatar answered Oct 16 '22 21:10