force update the current branch – how?

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?

  • How to overwrite local tags with git fetch?
  • Fastest way to get git status in bash
  • Git repositories on VS Solutions instead of Projects
  • for loop over all git branches with certain name
  • Git: Automatically backing up all commits on creation
  • Can't find pushed repo on git server
  • Undo git update-index --skip-worktree
  • Git subtree. One common folder in two repositories
  • Create a git patch between repository and non-repository
  • How to measure IOPS for a command in linux?
  • git merge --no-commit vs git cherry-pick --no-commit
  • Github: looking for a smart Git setup with shared files
  • One Solution collect form web for “force update the current branch – how?”

    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.

    Git Baby is a git and github fan, let's start git clone.