开发者

git deleted a branch, but changes still staged on master

I was working on a branch in my git repo and just开发者_如何学Python 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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜