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

标签 git

我在使用git的时候遇到了一个很奇怪的问题,具体如下:

我从远程 pull 一个包,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状态显示如下:

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 中设置任何钩子(Hook)。我试图为这三个文件重置为 HEAD,但它确实有效,并且 git status 显示与上面相同。

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

提前致谢!并期待...

最佳答案

我的假设是,当您修改 conf 文件时,它可能也会向 XML 文件写入一些内容。请确认 XML 文件发生了什么变化

关于git add 命令暂存意外的额外文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38262193/

相关文章:

windows - Git远程端意外挂了

Git Bash 和 Composer - 无需扩展即可运行

GIT:应该使用武力吗?

git - 当我想从 git repo 中删除所有文件然后添加新文件时如何避免冲突

git - BitBucket - 创建存储库和子模块

git - Git 中的变更集是什么?

git - 如何解析 GIT 提交中的注释?

开始使用 token 后,Windows 客户端中的 git pull over ssh 挂起

git - 两个 github 帐户推送到同一个 repo

git - 在不区分大小写的文件系统上自动执行区分大小写的重命名的 git 提交