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?
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
.
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