[Git] Reset the current branch to match a remote branch

Created on November 30, 2026

You can combine git fetch and git reset --hard when you want to move the current local branch to the same commit as a remote branch.

Check the current branch and save any work you want to keep first. The reset discards staged and unstaged changes to tracked files and moves locally committed work out of the current branch's history if the target commit does not contain it. It can also remove untracked files that are in the way of tracked paths.

git fetch origin
git reset --hard origin/topic

origin/topic is the local remote-tracking reference for topic. Fetching refreshes that reference before the reset.

Git