如何追踪而不是阶段,以及如何取而不开,而不是追踪? [英] How to track but not stage and how to unstage but not untrack?
问题描述
- 如何追踪文件但不登陆它们?
- 如何在不解除提交文件的情况下取消提交文件? 我可以做一个初始提交来跟踪这些文件,并从那里跟踪我的文件。但有可能专门做我上面提到的问题吗?
我尝试使用 git add -N< expr>
但它跟踪文件并将其添加到commit:
PS C:\> git add -N fileA
PS C:\> git status
#在分支主机上
#要提交的更改:
#(使用git reset HEAD< file> ...停用)
#
#新文件:fileA
#
#没有为commit提交的更改:
#(使用git add< file> ...更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)
#
#修改:README.md
#修改:composer.lock
#modified:fileA
#
如果我做 git reset HEAD fileA
或 git rm --cached fileA
取消它的作用,但也会解除对文件的处理。
这个命令 git rm fileA
建议我使用标志-f来删除文件。
所以,有可能只跟踪,而不是阶段,并且只能暂停而不是未跟踪文件? 解决方案
更新2015)
我尝试使用
git add -N
但它跟踪文件并将其添加到提交中:
即将推出的Git 2.5(2015年第2季度) I have two concise questions: NOTE: I know that I can do an initial commit to track the files and start from there with my files tracked. But is possible to specifically do what I'm asking above ? I tried to use If I do So, It is possible to only track but not stage, and to only unstage but not untrack files ? Update (May 2015) I tried to use That is no longer the case with the upcoming Git 2.5 (Q2 2015). Original answer (March 2013) How I can unstage files for commit without untracking them ? this is the official way: But since it is a new file, you would untrack it as well (remove it from the index, without any previous commit referencing it). Starting tracking a file means having it in a index (stage) or a commit. I would recommend making a branch for those files, in order to add them/commit them there. That means that, for a new file, unstaged it means untrack it. See also "git - how to tell if a file is git tracked (by shell exit code)?". 这篇关于如何追踪而不是阶段,以及如何取而不开,而不是追踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
请参阅
(来源: Pro Git Book ,2.2 Git基础知识 - 记录对存储库的更改)
(谢谢, louisfischer ,以便更新/修复
/ p>
git add -N <expr>
but it tracks the file and add it for commit:PS C:\> git add -N fileA
PS C:\> git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: fileA
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README.md
# modified: composer.lock
# modified: fileA
#
git reset HEAD fileA
or git rm --cached fileA
unstages it but also untracks the file.
This command git rm fileA
suggest me to use the flag -f that removes the file fisically.
git add -N <expr>
but it tracks the file and add it for commit:
See "File doesn′t get into the commit after using git add -N
"
git reset HEAD fileA
See "What is Tracked files and Untracked files in the context of GIT?"
(Source: Pro Git Book, 2.2 Git Basics - Recording Changes to the Repository)
(Thank you, louisfischer, for the update/fix in the comments)