git删除了一个分支,但变化仍然在master上进行 [英] git deleted a branch, but changes still staged on master

查看:144
本文介绍了git删除了一个分支,但变化仍然在master上进行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



所以,我没有提交任何提交的内容更改并检出我的主分支,然后执行 git分支-Dbranch_to_remove



然而,文件仍然在我的目录中,并且更改仍然在我的主分支上进行提交。



如何摆脱所有这些更改?

解决方案

您可以将您的工作目录重置为主人:

  git checkout master 
git reset --hard HEAD

删除未跟踪文件,我通常使用(修改以下@Mark Longair的注释):

  git ls-files --exclude-standard --others --directory -z | xargs -0 rm -i 

编辑

或者使用 git clean -d 作为Noufal在另一个答案(现已删除)中的评论中提出的建议。


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?

解决方案

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

这篇关于git删除了一个分支,但变化仍然在master上进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆