git add 命令暂存了意外的额外文件

3

当我使用git时,遇到了一个非常奇怪的问题,详细情况如下:

我从远程拉取了一个包,但是git status显示它是最新的:

XXXService weiheng$ git status
On branch mainline
Your branch is up-to-date with 'origin/mainline'.
nothing to commit, working directory clean

XXXService weiheng$ git pull
Already up-to-date.

然后我修改了一个文件,git status显示如下:

XXXService weiheng$ git status
On branch mainline
Your branch is up-to-date with 'origin/mainline'.
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:   configuration/app/XXXService.conf

no changes added to commit (use "git add" and/or "git commit -a")

好的,目前看起来一切都很正常。但是,当使用git add命令将更改暂存时,还会添加三个额外的文件:

XXXService weiheng$ git add configuration/app/XXXService.cfg
XXXService weiheng$ git status
On branch mainline
Your branch is up-to-date with 'origin/mainline'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified:   configuration/app/XXXService.conf
new file:   configuration/tomcat-setup-env-Alpha/RemoteDebugging.xml
new file:   configuration/tomcat-setup-env-Beta/RemoteDebugging.xml
new file:   configuration/tomcat-setup-env-Gamma/RemoteDebugging.xml

我没有在git中设置任何挂钩。我尝试将这三个文件重置为HEAD,但是它不起作用,而且git状态显示与上述相同。

XXXService weiheng$ git reset HEAD configuration/tomcat-setup-env-Alpha/RemoteDebugging.xml
XXXService weiheng$ git status
On branch mainline
Your branch is up-to-date with 'origin/mainline'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified:   configuration/app/XXXService.conf
new file:   configuration/tomcat-setup-env-Alpha/RemoteDebugging.xml
new file:   configuration/tomcat-setup-env-Beta/RemoteDebugging.xml
new file:   configuration/tomcat-setup-env-Gamma/RemoteDebugging.xml

感谢您的提前帮助!期待着...(此处缺少上下文,无法准确翻译)

我不知道这里发生了什么,但是我注意到在你的 git reset 之前,configuration/app/XXXservice .conf 被标记为已修改,而在你的 git reset 之后,configuration/ brazil-config /app/XXXservice .cfg 被标记为已修改。它们完全不匹配。 - torek
@torek 抱歉,这是一个打字错误。我已经更改为XXXService.conf。 - J.Wei
1
其中一个仍然有brazil-config,而其他的没有。 如果您正在编辑 Git 的输出,则可能会使任何可能看到此问题的人更难以识别该问题。 - torek
我认为 XxxService.conf 已经包含在 hit 中了。你不需要再添加它。只需提交即可。 - Twinkle
@Twinkle,它没有起作用。我使用了“git commit”,结果所有四个文件都被提交了。谢谢! - J.Wei
显示剩余2条评论
1个回答

1
我的假设是当您修改配置文件时,它可能也会向XML文件中写入一些内容。请确认XML文件中发生了哪些更改。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接