仅使用Git卸载新文件 [英] Unstage only new files using Git

查看:86
本文介绍了仅使用Git卸载新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意外地发起了很多更改,包括我不想提交的新文件。



如何取消或重置仅新文件? / p>

我不是在寻找任何类型的脚本;我正在寻找核心的git功能来暴露并记录在SO下的一个有意义的主题标题。

你可能可以做到这一点的一种方式是暂停/重置所有内容,然后只重新设置你想要的内容:

  git重置HEAD ./ 
git add -u
#-u阶段更改为跟踪文件,并且不会暂存新文件。


I've accidentally staged a lot of changes including new files that I do not want to commit.

How can I unstage or reset only the new files?

I am not looking for a script of any kind; I am looking for core git functionality to be exposed and documented here on SO under a meaningful topic title.

解决方案

One way you may be able to do this is to unstage / reset everything and then re-stage only what you wanted:

git reset HEAD ./
git add -u
# -u stages changes to tracked files, and will not stage new files.

这篇关于仅使用Git卸载新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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