我如何看待Git历史是否被重写

时间:2014-11-25 15:35:15

标签: git github

我正在追踪一个问题,其中一些提交似乎从分支中丢失了。我无法解释发生的事情,但需要了解是否需要与开发人员一起提出任何培训/流程问题。

情况:创建了一个功能分支,并对其进行了一些提交(对javascript文件进行了一些更改)。是时候将功能分支合并回主服务器了,但是发现缺少某个功能。原始开发人员给了我提交哈希,我可以在github上看到它并声称它位于功能分支上,但是当我查看分支上的javascript文件的历史记录时,这两个提交根本就不存在。

有人重写了分支的历史并删除了提交吗?

1 个答案:

答案 0 :(得分:0)

如果你有哈希,你可以随时

git branch --contains 122345abcd

其中12345abcd是您丢失的哈希。

同样,你可以

git rev-list --all | grep 12345abcd

您可以使用

git log --cherry-mark --left-right --graph --oneline 12345abcd^...feature_branch

识别分支机构之间的重写(樱桃挑选/重新定位)提交。另请参阅https://www.kernel.org/pub/software/scm/git/docs/git-log.html

--cherry-mark
Like --cherry-pick (see below) but mark equivalent commits with = rather than omitting them, and inequivalent ones with +.

--cherry-pick
Omit any commit that introduces the same change as another commit on the "other side" when the set of commits are limited with symmetric difference.

For example, if you have two branches, A and B, a usual way to list all commits on only one side of them is with --left-right (see the example below in the description of the --left-right option). It however shows the commits that were cherry-picked from the other branch (for example, "3rd on b" may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.
相关问题