如何在git checkout上仅还原已修改的文件? [英] How can I restore only the modified files on a git checkout?

查看:287
本文介绍了如何在git checkout上仅还原已修改的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个包含数百个文件的目录.我修改了其中几个,但后来我意识到自己的修改很糟糕.如果我这样做:

Say I have a directory containing hundreds of files. I modify several of them, but afterwards I realize my changes are bad. If I do:

git checkout whole_folder

然后再次检查所有内容,我必须重新编译所有内容.有没有一种方法可以使签出仅影响已修改的文件,还是需要在每个文件上分别运行checkout?

Then everything gets checked out again, and I have to recompile everything. Is there a way to make checkout affect only modified files, or do I need to run checkout on each file separately?

推荐答案

尝试一下:

$ git checkout `git ls-files -m`

-m仅列出修改后的文件.

-m lists only the modified files.

这篇关于如何在git checkout上仅还原已修改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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