能否在不将档案列入索引的情况下开始对文件进行跟踪?
我有新档案,我想在<代码>git Clean上保存,但有可能在下一个承诺期之前发生变化。 现在我是否在指数中加入,然后在承诺之前再次加入?
能否在不将档案列入索引的情况下开始对文件进行跟踪?
我有新档案,我想在<代码>git Clean上保存,但有可能在下一个承诺期之前发生变化。 现在我是否在指数中加入,然后在承诺之前再次加入?
请参看<代码>git 添加——intent-to-add(或git 添加-N
。 https://git-scm.com/docs/git-add#git-add-N"rel=“noreferer”
-N --intent-to-add
只记录这条路稍后会增加这一事实。 这条道路的条目被列入无内容的指数。 除其他外,这尤其有助于显示这些档案的未变内容,包括<条码>git diff,并以<条码>表示承诺。
See the What does git add --intent-to-add or -N do and when should it be used? question for more information.
可在发射前使用<代码>git 添加,然后git reset
。
<代码>add-N(i-t-a,“intent to Add”,目的是“开始在Gite跟踪一个档案,而不添加索引”:
由于意图上加一条目的实施细节,
- the current "
git diff
" (i.e. no treeish or--cached
argument) would show the changes in the i-t-a file, but it does not mark the file as new,- while "
diff --cached
" would mark the file as new while showing its content as empty.
Git 2.19 (Q3 2018) changes that; since "git diff
" compares the index and the working tree.
For paths added with intent-to-add bit, the command shows the full contents
of them as added, but the paths themselves were not marked as new files.
They are now shown as new by default.
See commit cff5dc0, commit 8fc8f05, commit 0231ae7, commit ba4e356 (26 May 2018) by Nguyễn Thái Ngọc Duy (pclouds
).
(Merged by Junio C Hamano -- gitster
-- in commit ac997db, 25 Jun 2018)
在Gite 2.19之前:
$ git diff | $ diff --cached --------------------------------|------------------------------- diff --git a/new b/new | diff --git a/new b/new index e69de29..5ad28e2 100644 | new file mode 100644 --- a/new | index 0000000..e69de29 +++ b/new | @@ -0,0 +1 @@ | +haha |
One evidence of the current output being wrong is that, the output from "
git diff
" (with ita entries) cannot be applied because it assumes empty files exist before applying.2.1 See on
-ita-invisible-in-index
(,git diff-capple/code>改为“git diff
。$ git diff | $ diff --cached --------------------------------|------------------------------- diff --git a/new b/new | new file mode 100644 | index 0000000..5ad28e2 | --- /dev/null | +++ b/new | @@ -0,0 +1 @@ | +haha |
This option is on by default in
git-status
but we need more fixup in rename detection code (commit bc3dca0, Jan. 2018, Git 2.17.0). Luckily we don t need to do anything else for the rename detection code indiff.c
(wt-status.c
uses a customized one).
“git diff-files
” 教授Gite 2.28(Q32020)说,标明“意向”的道路是新的档案,没有从空洞的布道上改动。
See commit feea694 (20 Jun 2020) by Srinidhi Kaushik (clickyotomy
).
(Merged by Junio C Hamano -- gitster
-- in commit 298d704, 29 Jun 2020)
diff-files
: treat "i-t-a
" files as "not-in-index
"临时代办
The
diff-files command and related commands which call the function
cmd_diff_files() , consider the "intent-to-add" files as a part of the index when comparing the work-tree against it.
This was previously addressed in commits 0231ae71d3 (diff
: turn --ita-invisible-in-index on by default, 2018-05-26) and 425a28e0a4 (diff-lib
: allow ita entries treated as "not yet exist in index", 2016-10-24) by turning the option--ita-invisible-in-index
(introduced in b42b451919 ("diff
: add --ita-[in]visible-in-index", 2016-10-24, Git v2.11.0-rc0 -- merge) on by default.<编码>diff-files (and
add -p
, as a result) to show i-t-a file as new,ita_invisible_in_index
will be found as well as otherwise.
Warning: if you are using exclusion (lowercase) and inclusion (uppercase) in a git diff-filter, use Git 2.36 (Q2 2022).
Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...
I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...
I have a svn repo with various apps as subdirectory of a single svn repo. That worked because I could have checked out a partial, repo. As I cant do that with git obviously I need multiple repos. I ...
I understand how to merge branches together in git, and I love how easy it makes it. I have a branch that looks like this: project/ |--subproj1/ | |---(files) | |--subproj2/ |---(files) A ...
We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...
I get this on every git svn command I try. I am using git version 1.6.4.2 on OS 10.6 The initial git svn fetch works, and i can do further fetches after that, but they do not enter the log or update ...
Given I have a master branch and a other branch. In the other branch are files I don t want to commit (e.g. log files) so I ignored them in .gitignore. When I switch to the master branch, these ...
Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...