Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JamesKontargyris/360ec1668647195ba2ef874d42b79f0c to your computer and use it in GitHub Desktop.
Save JamesKontargyris/360ec1668647195ba2ef874d42b79f0c to your computer and use it in GitHub Desktop.
Git: fetch remote branch and force hard reset
git fetch --all
git reset --hard origin/master
OR If you are on some other branch
git reset --hard origin/your_branch
Explanation:
git fetch downloads the latest from remote without trying to merge or rebase anything.
Then the git reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment