我在使用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/