Delete all the local files and download a fresh copy from git
本问题已经有最佳答案,请猛点这里访问。
我理解在本地删除所有内容并重新开始是可能的,但我想知道,当您不需要使用git命令在本地保留任何内容时,是否有一种更简单的方法。
例如,如果我在本地添加了一些我想删除的文件,并且只下载最新的主副本。
Please note: Reading the other questions (there are many; I read them before posting), git help & blog posts I wasn't sure if it's going to reset my repository or not which is why I posted this question; I imagine someone with
the same exact issue might want to validate and that's what I have done through comments. and that is why I don't think its a duplicate although it might have the same response.
号
要删除本地添加的Git提交,请执行以下操作:
1 | git reset --hard HEAD^ |
要删除删除未提交的文件,请执行以下操作:
1 | git clean -fd |
号
在此处查看其他Git清理选项:
https://git-scm.com/docs/git-clean
然后再做
1 2 | git fetch git rebase origin/master |
或
1 | git pull |
。