Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

force update the current branch - how?

Tags:

git

I'm on the my-backup branch. Now I do git fetch origin my-backup and origin/my-backup is updated and I see that it was forced pushed. Now I need to updated my local my-backup branch to point to origin/my-backup branch. I do git branch -f my-backup origin/my-backup but get the warning: fatal: Cannot force update the current branch. What is the best way to force update current branch to remote without checking out other branch?

like image 499
Max Koretskyi Avatar asked Apr 10 '15 10:04

Max Koretskyi


1 Answers

Use reset

git reset --hard origin/my-backup

This will reset your current branch (my-backup) with losing all your local changes.


git branch -f my-backup origin/my-backup is allowed only if your current branch is not my-backup.

like image 164
phts Avatar answered Sep 27 '22 21:09

phts