DEV Community

Iano Njuguna
Iano Njuguna

Posted on

Answer: Undo local changes in Git

Adapted from answers by Dan Moulding and knittl

Setting your branch to exactly match a remote branch, including clearing untracked files, can be done in three steps:

git fetch origin
git reset --hard origin/<branch name>
git clean -f -d

Explanation: git fetch grabs the latest version of the repository. git

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.