警告:您运行 'git add' 时既没有 '-A (--all)' 也没有 '--ignore-removal'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23027678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal'
提问by Salvador Dali
I tried to add my files to staging on another branch in git. Basically I have done the following
我尝试将我的文件添加到 git 中的另一个分支上。基本上我做了以下
git checkout -b <newBranch>
- Modified some files in that new branch
- git add .
git checkout -b <newBranch>
- 修改了那个新分支中的一些文件
- git 添加。
But got the following warning (I have not found anything like this in SO and surprisingly on by googling. It is very surprising for me):
但是得到了以下警告(我在 SO 中没有发现任何类似的东西,并且通过谷歌搜索令人惊讶。这对我来说非常令人惊讶):
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal', whose behaviour will change in Git 2.0 with respect to paths you removed. Paths like 'thePathToFileIDeleted' that are removed from your working tree are ignored with this version of Git.
'git add --ignore-removal ', which is the current default, ignores paths you removed from your working tree.
'git add --all ' will let you also record the removals.
Run 'git status' to check the paths you removed from your working tree.
警告:您运行 'git add' 时没有使用 '-A (--all)' 或 '--ignore-removal',它们的行为将在 Git 2.0 中根据您删除的路径而改变。此版本的 Git 会忽略从工作树中删除的诸如“thePathToFileIDeleted”之类的路径。
'git add --ignore-removal ',这是当前的默认值,会忽略您从工作树中删除的路径。
'git add --all ' 会让你也记录删除。
运行 'git status' 以检查您从工作树中删除的路径。
Does anyone know what does it mean and what should I do in the following situation? My git version 1.8.3.2
有谁知道这是什么意思,在以下情况下我应该怎么做?我的git version 1.8.3.2
回答by merlin2011
It is saying that you should use either git add -A
or git add --ignore-removal .
, because git add .
will have a different behavior in the newer version of git. Since it says the current version will ignore deleted paths, my best guess is that the next version will default to including them.
这是说您应该使用git add -A
或git add --ignore-removal .
,因为git add .
在较新版本的 git 中会有不同的行为。由于它说当前版本将忽略已删除的路径,我最好的猜测是下一个版本将默认包含它们。
It wants you to be explicit about what whether you want to stage deleted paths in the current directory.
它希望您明确说明是否要在当前目录中暂存已删除的路径。
If you want to add deleted paths, you should use git add -A
.
如果要添加已删除的路径,则应使用git add -A
.
If you do not want to add deleted paths, you should use git add --ignore-removal .
如果您不想添加已删除的路径,则应使用 git add --ignore-removal .
I think it is merely trying to warn you so that you will know that your command will do something unexpected (ie different from now) if you upgrade git, so you can take one of the above two options or just make a note of the coming change and move on, with the understanding that you are currently ignoring deleted paths.
我认为它只是试图警告你,以便你知道如果升级 git,你的命令会做一些意想不到的事情(即与现在不同),所以你可以选择上述两个选项之一,或者只是记下即将到来的更改并继续,了解您当前正在忽略已删除的路径。
回答by Salvador Dali
Apparently this is not really a big deal right now, because everything worked correct in my case (I was able to commit my stage, merge branches and push everything to the server with no problems).
显然,这现在并不是什么大问题,因为在我的情况下一切正常(我能够提交我的阶段,合并分支并将所有内容推送到服务器,没有任何问题)。
The problem I encountered is because I deleted some file (I used similar procedure previously for a lot of time with the no warnings). Based from my understanding git is just telling me that the current format is already deprecated and will be changed in version 2. It looks like I have to use git add -A to actually remove my file from staging.
我遇到的问题是因为我删除了一些文件(我以前使用过类似的程序很多时间都没有警告)。根据我的理解,git 只是告诉我当前格式已被弃用,并将在版本 2 中更改。看起来我必须使用 git add -A 来实际从暂存中删除我的文件。
回答by Nguyen Van Vinh
I also meet same problem. My context:
我也遇到同样的问题。我的背景:
- A directory called
ABC
exists - Delete the directory
- Create new symlink name
ABC
point to aDEF
directory. - Run
git status
. The problem occurs.
ABC
存在一个名为的目录- 删除目录
- 创建
ABC
指向DEF
目录的新符号链接名称。 - 运行
git status
。出现问题。
Solutions: Belong to your purpose.
解决方案:属于你的目的。
- You can run one of that both commands.
- Or create new directory to backup
DEF
directory of theABC
symlink. So you can track them by git.
- 您可以运行这两个命令之一。
- 或者创建新目录来备份符号链接的
DEF
目录ABC
。所以你可以通过 git 跟踪它们。