Git日志与现实不匹配
关于我在这里的问题: 这事又发生了,我不明白怎么回事。问题是,在提交过程中更改了一行代码,但旧的代码行存在于文件的当前repo版本中,这看起来很奇怪。有人知道这是怎么发生的吗?我们是如何避免的 该行是create_标记方法的函数头 更改行的提交(如预期的那样): 接下来的两次提交是历史上继上述提交之后的唯一提交,据我所知,它们不会以任何方式改变所讨论的行:Git日志与现实不匹配,git,git-commit,Git,Git Commit,关于我在这里的问题: 这事又发生了,我不明白怎么回事。问题是,在提交过程中更改了一行代码,但旧的代码行存在于文件的当前repo版本中,这看起来很奇怪。有人知道这是怎么发生的吗?我们是如何避免的 该行是create_标记方法的函数头 更改行的提交(如预期的那样): 接下来的两次提交是历史上继上述提交之后的唯一提交,据我所知,它们不会以任何方式改变所讨论的行: commit 2ab5fb14765caa269c027e8c57b11232b0441625 Author: xxx Date: Th
commit 2ab5fb14765caa269c027e8c57b11232b0441625
Author: xxx
Date: Thu Jul 4 13:58:26 2013
Comment
diff --git a/lib/services/MarkingService.class.php b/lib/services/MarkingService.class.php
index 66a33f7..c553876 100644
--- a/lib/services/MarkingService.class.php
+++ b/lib/services/MarkingService.class.php
@@ -8,32 +8,6 @@ class MarkingService {
return $instance;
}
- public static function getCoordinates(lmMarking $marking)
- {
- $returnValue = array($marking->getLatitude() . ',' . $marking->getLongitude());
-
- if (0 < $marking->getLatitude2()) {
- $returnValue[] = $marking->getLatitude2() . ',' . $marking->getLongitude2();
- }
-
- return $returnValue;
- }
-
- public static function getCoordinatesJavascript(lmMarking $marking)
- {
- return '[' . implode(',', self::getCoordinates($marking)) . ']';
- }
-
public function create_marking($category, $timestamp, $field_id, $lat, $lon, $accuracy, $lat2 = null, $lon2 = null, $accuracy2 = null, $spread = null, $depth = null, $comment = null) {
$this->validate_category($category);
$this->validate_timestamp($timestamp);
由于某些原因,我无法理解,文件中的行现在是
public function create_marking($category, $timestamp, $field_id, $lat, $lon, $accuracy, $lat2 = null, $lon2 = null, $accuracy2 = null, $spread = null, $depth = null, $comment = null) {
我做错了什么
编辑
git状态的输出
$ git status
# On branch master
nothing to commit, working directory clean
git日志的输出
$ git log lib/services/MarkingService.class.php
commit d152befa9977b8fc13df9f3ea3f756217751cb0d
Merge: 77b20e2 2ab5fb1
Author: xxx
Date: Thu Jul 4 14:43:26 2013 +0300
Changed the format of Markings block in Sync API method.
Send markings coordinates in the API in the new format
commit 2ab5fb14765caa269c027e8c57b11232b0441625
Author: xxx
Date: Thu Jul 4 13:58:26 2013 +0300
Changed the format of Markings block in Sync API method.
Send markings coordinates in the API in the new format
commit 925ec3c11006ccca37cf684443d0fad3e1781dca
Author: xxx
Date: Tue Jun 4 14:55:52 2013 +0300
Changed the makrings coordinates structure.
Allow more points in CreateMarking
git日志--单线--图形
当您拉取并执行合并时,commit
2ab5fb14765caa269c027e8c57b1232b0441625
删除了您所做更改附近的一大块代码,git使用该行的提交版本错误地解决了合并问题。您可以在该提交的修补程序中看到该行
Git不跟踪行的变化。它跟踪给定点的文件状态
Git不会以这种方式考虑或存储数据。相反,Git认为
它的数据更像是小型文件系统的一组快照。每一个
当您在Git中提交或保存项目状态时,它会
基本上就是拍下你所有文件的样子
捕捉并存储对该快照的引用。为了提高效率,如果
文件没有改变,Git不再存储文件,只是一个链接
到它已存储的上一个相同文件
所以Git将您拉入的提交视为对您修改的行的更改,并通过选择行“解析”合并
我以前见过这种情况,通常是因为删除/重新排序了大量代码,而这些代码恰好位于发生其他更改的地方。我建议在更新本地分支时使用git-pull--rebase
或git-rebase
这将把您的本地提交移动到远程上已有的任何提交之后,如果git在应用提交时遇到困难,将要求您更改提交。这也保持了历史记录的线性,不会让git resolve错误地在您身上合并。git status和git log lib/services/MarkingService.class.php的输出是什么?我还尝试重置为引入所需更改的提交,但这一行仍然是旧版本。如果您查看commit 2ab5fb14765caa269,所讨论的这一行就是旧版本。更新分支机构时,您是在执行
git merge
还是git rebase
?@Koraktor-将信息添加到我的question@Schleis-我在用Merge谢谢,我试试看。这看起来很奇怪,因为这一行在提交的差异中没有显示为changed。它在提交中没有标记为changed的原因是git正在比较其父提交和自身之间的文件状态。在那次承诺中,这一行没有改变。因此,当查看补丁时,你看不到任何变化。嗯-这基本上意味着,你不能信任输出?由于它显然没有反映对fileno的实际更改,问题是“更改”是什么——默认情况下,git说“与第一个父项相比有什么不同”。如果您想查看针对双亲的更改,则需要将-c
添加到git日志中。
$ git status
# On branch master
nothing to commit, working directory clean
$ git log lib/services/MarkingService.class.php
commit d152befa9977b8fc13df9f3ea3f756217751cb0d
Merge: 77b20e2 2ab5fb1
Author: xxx
Date: Thu Jul 4 14:43:26 2013 +0300
Changed the format of Markings block in Sync API method.
Send markings coordinates in the API in the new format
commit 2ab5fb14765caa269c027e8c57b11232b0441625
Author: xxx
Date: Thu Jul 4 13:58:26 2013 +0300
Changed the format of Markings block in Sync API method.
Send markings coordinates in the API in the new format
commit 925ec3c11006ccca37cf684443d0fad3e1781dca
Author: xxx
Date: Tue Jun 4 14:55:52 2013 +0300
Changed the makrings coordinates structure.
Allow more points in CreateMarking
$ git log --oneline --graph lib/services/MarkingService.class.php
* d152bef Changed the format of Markings block in Sync API method. Send markings coordinates in the API in the new format
|\
| * 2ab5fb1 Changed the format of Markings block in Sync API method. Send markings coordinates in the API in the new format
* | 925ec3c Changed the makrings coordinates structure. Allow more points in CreateMarking
|/
* bacfb14 An intermediate commit. HOTFIX: Fix markings
* 6479513 LETFARM-1863 DB and API support for markings