假设没有任何文件被暂存,重置所有已完成工作的推荐方法是什么,但保留文件:
app/models/a.rb
app/views/a/index.html.rb
config/foo.rb
config/bar.rb
在 app/models/ 和 app/views/ 目录中还存在其他我不想保留的脏文件。
假设没有任何文件被暂存,重置所有已完成工作的推荐方法是什么,但保留文件:
app/models/a.rb
app/views/a/index.html.rb
config/foo.rb
config/bar.rb
在 app/models/ 和 app/views/ 目录中还存在其他我不想保留的脏文件。
git add app/models/a.rb app/views/a/index.html.rb config/foo.rb config/bar.rb
git checkout .
一种方法是先git commit这四个文件,然后硬重置,接着撤销提交:
git add <files to keep>
git commit -m "temp"
git reset --hard
git reset HEAD~
git-clean
就可以解决问题。 如果不确定,请先使用 --dry-run
开关,并注意 --exclude
开关。
git clean -fd
更好。 - Ron Garritycheckout
适用于已跟踪文件,而clean
适用于未跟踪文件。 - kangit add
将文件添加到暂存区,然后git checkout .
用于处理未暂存的文件。 - phoxd