当我跑步时git add --intent-to-add .
所有未跟踪的文件都从“未跟踪的文件”更改了状态(git status -s
showed ??
) 到“未暂存提交的更改”(git status -s
现在显示A
)。现在,每当我跑步时git diff
我也看到了新文件。如何恢复这些状态更改,以便它们再次变得“未跟踪”?
Use git reset --mixed
为了这。
After --intent-to-add
,该文件将被放置在索引中,但不包含其内容。您希望将其从索引中删除,而不在工作树中更改它。这正是git reset --mixed
does.
$ echo "some content.txt" > file.txt
$ git status ; echo "###" ; git status -s
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
file.txt
nothing added to commit but untracked files present (use "git add" to track)
###
?? file.txt
# This will add the file to the index but without its content.
# Hence, for Git all the content has "changed".
$ git add --intent-to-add .
$ git status ; echo "###" ; git status -s
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
new file: file.txt
no changes added to commit (use "git add" and/or "git commit -a")
###
A file.txt
$ git diff # show the content of file.txt
# Resets the index so that file.txt becomes completely new for Git.
$ git reset --mixed
$ git status ; echo "###" ; git status -s
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
file.txt
nothing added to commit but untracked files present (use "git add" to track)
###
?? file.txt
$ git diff # doesn't show the content of file.txt
请注意,您可以使用-N
for git reset --mixed
具体到not从索引中删除未跟踪的文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)