在svn工作目录下,我可以
- 对工作目录中的文件进行一些修改
- 删除我所做的所有更改 'rm 该目录中的所有源文件,但保留我的 .svn 目录)
- 使用“svn update”检索主干应该做什么,svn 会将所有源下载回我的工作目录。
git 中是否有等效的命令?你能告诉我怎么做吗?
最佳答案
git reset --hard
它是“git reset --hard HEAD
”的同义词,应该就是您要查找的内容。
谨慎使用它,因为它会有效地删除您工作目录中的任何当前更改。参见“Undoing in Git”
注:如Charles Bailey在评论中提到,和in his answer ,这不会删除未跟踪的文件。
为此git clean是正确的工具。查看他的 answer for more ,还有 SO 问题“How do you remove untracked files from your git working copy?”,或 Git-Ready 文章“cleaning up untracked files”。
So if we wanted to do a major cleanup:
$ git clean -n -d -x
That command would clean up files listed under the project’s
.gitignore
file as well as removing other files and directories that aren’t necessary.
As always use precaution when running git clean, and make sure to double check what you’re really deleting.
请注意,您可能需要 move your untracked files instead .
关于svn - 'rm' + 'svn update' 在 Git 中等效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1163231/