什么是在git中取消部分新文件的最快方法? [英] What is the fastest way to unstage parts of a new file in git?
问题描述
当我想将一个新文件拆分为多个提交时,我可以使用 git添加-N< file>
,然后交互式地使用 git gui
。然而,当我在登台时出错时, git gui
不会让我暂停各条线,因为它是一个新文件(这对我来说似乎是一个错误)。当然,我总是可以取消整个文件并重新开始,但我想知道是否有更有效的方法来做到这一点。
我正在使用 git 1.7.5
。
为了澄清这个问题, em> new aka
/ p>
git reset -p
这将使您可以使用标准命令行界面管理hunks,从索引中选择不间断的hunk。这与 git add -p
相反。 。
UPDATE
好的,您似乎无法选择性地选择不同的阶段当文件是新的时候,鉴于git-gui和标准的git hunk编辑器都不允许这样做,所以这可能是不可能的。
When I want to split up a new file into several commits I can git add -N <file>
and then interactively stage lines using git gui
. When I make a mistake while staging, however, git gui
won't let me unstage individual lines because it is a new file (which seems like a bug to me). Of course I can always unstage the whole file and start over again, but I am wondering whether there is a more efficient way to do so.
I am using git 1.7.5
.
To clarify, this question is specific to new aka untracked files!
From the command line type:
git reset -p
This will let you selectivelty unstage hunks from the index using the standard command-line interface for managing hunks.. This is the opposite of git add -p
.
UPDATE
OK, it would appear that you cannot selectively stage different hunks when the file is new. Given that git-gui and the standard git hunk editor both do not allow this, it probably isn't possible.
这篇关于什么是在git中取消部分新文件的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!