git - 文件不在最新提交上
问题描述
我们最近在工作的 git 中遇到了一个奇怪的行为,因为没有人真正理解它是如何发生的,所以我将在这里尝试一下;)
我们最近遇到了一个问题,文件没有更新到最新的提交,我们无法弄清楚这是如何发生的/如何在将来防止它并正确修复它。任何帮助深表感谢
现在让我们首先更详细地描述我们看到的问题,然后描述我们使用的工作流程(因为我有点担心它只是那样。我们工作流程中的一个问题)
我们有一个文件。让我们称之为index.php
。我们将分支master
(状态正确的地方)合并到develop
分支中,文件没有收到任何更新。
经过进一步检查,我们发现以下
git log -p index.php
commit 4689e60f87df4af989b7020a90b1cb186c6d5e04
Author: A Colleague
Date: Fri Sep 25 14:50:24 2020 +0200
Message // We did some stuff
diff --git a/index.php b/index.php
index cfde79447..b82010ac5 100644
commit 176a2c3142dfd4c20606f0838e99efbd55da91a4
Author: Another Colleague
Date: Mon Apr 29 08:42:14 2019 +0200
Message // Did some other stuff
diff --git a/index.php b/index.php
old mode 100755
new mode 100644
index 264b5a5b2..cfde79447
我们意识到我刚刚提交的更改不存在。为什么不?我们进一步研究了它,我跑了一个
git log -p --follow index.php
看看吧。我们得到了丢失的提交
commit 854ba270959151982c2ccc14573a47ae5ea568cc
Author: Me Myself and I
Date: Wed Nov 11 18:57:46 2020 +0100
Changes // I did the stuff I needed
diff --git a/index.php b/index.php
index cfde79447..b3f7bd07e 100644
commit 4689e60f87df4af989b7020a90b1cb186c6d5e04
Author: A Colleague
Date: Fri Sep 25 14:50:24 2020 +0200
Message // We did some stuff
diff --git a/index.php b/index.php
index cfde79447..b82010ac5 100644
commit 176a2c3142dfd4c20606f0838e99efbd55da91a4
Author: Another Colleague
Date: Mon Apr 29 08:42:14 2019 +0200
Message // Did some other stuff
diff --git a/index.php b/index.php
old mode 100755
new mode 100644
index 264b5a5b2..cfde79447
所以。我还看到的是(如每条提交日志消息的最后一行所示。我们看到了哈希的变化。我不太确定这个哈希到底是干什么用的。但是你可以看到我正在寻找的丢失的提交for 有一个不同的开始。它在实际提交之前使用了提交之前的提交。
即使更改了文件名,根据man git log
以下标志也会遵循提交历史记录。但是我没有看到更改文件名的任何指示?
我想这是主要问题。但是我不确定这是如何发生的/如何防止它以及如果它再次发生如何正确修复它
关于我们如何使用 git 的说明
为简单起见
我们有两个存储库。回购 A 和回购 B
每个回购包含至少 3 个品牌
- 掌握
- 发布
- 开发
如果我们处理特性,我们会从主树创建一个新分支,将它与 no-ff 合并到开发中。一旦客户说它准备好发布分支,就会通过 no-ff 合并到分支发布中
现在可能发生我们需要将内容从 Repo A 复制到 Repo B 的情况。
我们现在如何做到这一点。
- 我们进入回购 A。
- 将 Repo B 添加为远程存储库
- 在 Repo B 中创建一个新的远程分支
- 将所有更改挑选到该远程分支中
- 通过 no-ff 将该远程分支合并到目标远程分支
我对造成这种情况的想法/解决方案持开放态度,如果您有任何问题,请直接询问:) 谢谢!
编辑:正如评论所要求的,输出git log --graph --oneline --all
我后来添加的提交现在是第二个。我不知道为什么
...
* 4689e60f8 Message // We did some stuff
| diff --git a/index.php b/index.php
| index cfde79447..b82010ac5 100644
...
| * 854ba2709 Changes // I did the stuff I needed
|/
| diff --git a/index.php b/index.php
| index cfde79447..b3f7bd07e 100644
解决方案
推荐阅读
- apache-spark - Spark推荐的自定义日志记录方式
- tomcat - Tomcat 中的自定义 ETag 8/9/10
- javascript - 如何避免在本机反应中重新渲染?
- python - 如何加速python函数(numpy)
- java - 最有效的算法和 BigO 表示法
- function - 这个语法是什么意思?(持续时间)-> 字符串?
- discord - 票务系统 Discord.js v.13
- google-sheets - countifs 奇怪的行为——使用“通配符”的结果仍然不等于总数
- mobile - 响应式移动应用程序不信任证书颁发机构
- r - 从闪亮的日历中删除几个月