Github 领先/落后指标的含义

发布于 2024-11-19 17:27:18 字数 102 浏览 7 评论 0原文

用简单的语言(希望有一个简单的例子)来说,Github 存储库分支上的领先/落后指标意味着什么?

该分支的影响及其受到的关注是什么?对于分支机构来说,“落后”是一个坏兆头吗?

In plain language (hopefully with a simple example), what do the ahead/behind metrics on a Github repo's branch mean?

And what are the implications for that branch and the attention it's receiving? Is being "behind" a bad sign for a branch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

百变从容 2024-11-26 17:27:18

前方是该分支上不存在于基本分支上的提交数量。后面是基础分支上不存在于该分支上的提交数量。

领先和落后几乎就像一种“年龄”指标。前面的数字大致告诉您如果合并该分支将对基本分支产生多大影响。后面的数字告诉您自该分支启动以来基础分支上发生了多少工作。

我发现后面的数字对于判断分支是否可能干净地合并非常有用。当基础分支上发生大量工作时,两个分支更有可能修改相同的行。当后面很大时,这表明您可能应该将基础分支合并到此分支中以进行同步。一旦你将基础分支合并到这个分支中,后面就会是0。

Ahead is the number of commits on this branch that do not exist on the base branch. Behind is the number of commits on the base branch that do not exist on this branch.

Ahead and behind are almost like a kind of "age" metric. The ahead number tells you roughly how much impact the branch will have on the base branch should it be merged. The behind number tells you how much work has happened on the base branch since this branch was started.

I find the behind number really useful for judging whether a branch is likely to merge cleanly. When a lot of work has happened on the base branch, it's more likely that the two branches have modified the same line(s). When behind is large, it's a sign that you should probably merge the base branch into this branch to sync up. Once you merge the base branch into this branch, behind will be 0.

揽清风入怀 2024-11-26 17:27:18

如果您更喜欢视觉类型,请看这里:

◈ - ◈ - A - ◈ - B
      \
        ◈ - C

A 落后 2 个提交,领先 B 0 个提交
BA 落后 0 次提交,领先 2 次提交
CA 落后 1 次提交、领先 2 次提交
CB 落后 3 次提交,领先 2 次提交,

因此“落后”意味着另一个分支已提交,而“领先”则意味着该分支已提交另一个则不然。

If you're more of a visual type, take a look here:

◈ - ◈ - A - ◈ - B
      \
        ◈ - C

A is 2 commits behind and 0 commits ahead of B
B is 0 commits behind and 2 commits ahead of A
C is 1 commit behind and 2 commits ahead of A
C is 3 commits behind and 2 commits ahead of B

So "behind" means the other branch has commits this one doesn't, and "ahead" means this branch has commits the other does not.

芯好空 2024-11-26 17:27:18

您可以在此项目中看到的指标描述,与存储库(如 master

  • GitHub 存储库与另一个存储库的另一个分支相比已完成的新提交数量:这些是后面提交:与其他回购相比落后当前的存储库(请参阅那些提交)。
  • 与当前存储库相比,另一个存储库的另一个分支已完成的新提交数量:这些是前方提交:与当前存储库相比,另一个存储库处于领先位置(请参阅那些提交)。

技术细节由脚本“确定哪些存储库位于原点之前/之后” 进行说明:
它是关于检查:

  • 哪些提交可以从另一个分支访问,但不能从本地分支访问:前方
    git rev-list "$localref..$anotherref"
  • 哪些提交可以从本地分支访问,但不能从其他分支访问:后面
    git rev-list“$anotherref..$localref”

The metrics like those you can see for this project describe, compare to a branch from the repo (like master):

  • the number of new commits that the GitHub repo has done compared to another branch of another repo: those are the behind commits: the other repo is behind compared to the current repo (see those commits).
  • the number of new commits another branch of another repo has done compared to the current repo: those are the ahead commits: the other repo is ahead compared to the current repo (see those commits).

The technical detail is illustrated by the script "determining which repos are ahead/behind origin":
It is about checking:

  • what commits are reachable from another branch, but not from the local branch: ahead
    git rev-list "$localref..$anotherref"
  • what commits are reachable from the local branch, but not from the other branch: behind
    git rev-list "$anotherref..$localref"
愚人国度 2024-11-26 17:27:18

需要注意的是,github 的“后面”也计算合并提交。您可以使用以下命令检查“后面”的内容: git log mybranch1 ^mybranch2 它应该显示相同数量的提交。如果您有合并提交,您可以在最后一个命令中使用 --no-merges 排除它们。

On thing to note is that github's "behind" also counts merge commits. You can check the "behind" stuff with: git log mybranch1 ^mybranch2 and it should show you the same number of commits. If you have merge commits you can exclude them with --no-merges in the last command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文