Rapture
Rapture

Reputation: 1896

git deleted a branch, but changes still staged on master

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

Answers (1)

Benoit Garret
Benoit Garret

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

Related Questions