Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active March 4, 2019 01:09
Show Gist options
  • Save ChristopherA/2171b8291d671fd08f938b9a2354082d to your computer and use it in GitHub Desktop.
Save ChristopherA/2171b8291d671fd08f938b9a2354082d to your computer and use it in GitHub Desktop.
Revert git repository to remote master

Setting your branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master

If you want to save your current branch's state before doing this (just in case), you can do:

git commit -a -m "Saving my work, just in case"
git branch my-saved-work

If you want to remove local files to have an exact copy of remote branch you do:

git clean -ffdx

To see what files will be removed (without actually removing them):

git clean -n -ffdx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment