我让 Git 将似乎是diff
命令的接口输出的内容添加到文件的行中:
$ git pull
U public_html/spider/spider.php
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 1 different commit each, respectively.
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: spider.php
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git diff spider.php
diff --cc public_html/spider/spider.php
index a89b8ef,4b091a7..0000000
--- a/public_html/spider/spider.php
+++ b/public_html/spider/spider.php
@@@ -136,13 -136,7 +136,17 @@@ if ( isset($_SERVER['HTTP_USER_AGENT']
$providersList[] = $p['name'];
}
}
++<<<<<<< HEAD
+
+ if ( ensure_fields($input, 'version') ) {
+ $output['providers'] = $providers;
+ } else {
+ $output['providers'] = $providersList;
+ }
+
++=======
+ $output['providers'] = $providersList;
++>>>>>>> 5de401379b275bdb805298fd3db919028506cc60
$logData['providers'] = implode(', ', $providersList);
echo json_encode($output);
$ git add spider.php
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 1 different commit each, respectively.
#
# Changes to be committed:
#
# modified: spider.php
#
现在,当我打开 spider.php 文件时,我发现它是直接从 VIM 复制的:
- bruno:spider$ vim spider.php
135 if ( $p['url']!='' ) {
136 $providersList[] = $p['name'];
137 }
138 }
139 <<<<<<< HEAD
140
141 if ( ensure_fields($input, 'version') ) {
142 $output['providers'] = $providers;
143 } else {
144 $output['providers'] = $providersList;
145 }
146
147 =======
148 $output['providers'] = $providersList;
149 >>>>>>> 5de401379b275bdb805298fd3db919028506cc60
150 $logData['providers'] = implode(', ', $providersList);
151
152 echo json_encode($output);
编辑文件的唯一机器是这台(本地)机器。在这种情况之前唯一不寻常的 Git 用法是commit --amend
在push
. 可能是造成这种情况的吗?如果不是,那又如何?这是一个 Git 错误吗,看起来确实如此?