Reputation: 1896
I was working on a branch in my git repo and just messed it up and wanted to just get rid of the changes.
So, I didn't commit the changes and checked out my master branch and then did git branch -D "branch_to_remove"
.
However, the files are still in my directory and the changes are still staged for commit on my master branch.
How can i get rid of all those changes?
Upvotes: 2
Views: 141
Reputation: 13675
You can reset your working directory to the master with:
git checkout master
git reset --hard HEAD
To delete the untracked files, I usually use (modified following @Mark Longair's comments):
git ls-files --exclude-standard --others --directory -z | xargs -0 rm -i
Edit
Or use git clean -d
as Noufal suggested in the comments in another answer (now deleted).
Upvotes: 3