gpt4 book ai didi

git - 与推送 sourcetree 相关的大块头意味着什么

转载 作者:IT王子 更新时间:2023-10-29 01:17:43 26 4
gpt4 key购买 nike

当我在“开发”分支上进行更改时,我在分支旁边看到一个向上箭头,告诉我将推送多少更改。让我感到困惑的是 sourcetree 如何决定数字是多少?

好像跟一个叫帅哥的东西有关?什么是帅哥?

是否有返回相同数字的等效 git 提交?

最佳答案

请注意,要推送的更改数量可能是指您领先于 origin/master 的提交数量,与 hunks 无关。要查看您领先于 master 的提交,您可以执行以下操作:

# get most recent commit found in both master and origin/master
mb=$(git merge-base master origin/master)
# show commits from that merge base to current head
git log $mb..HEAD

如果你想计算它,只需这样做:

mb=...
git log --pretty=oneline $mb..HEAD | wc -l

hunk是与 diff 相关的术语:

The format starts with the same two-line header as the context format, except that the original file is preceded by "---" and the new file is preceded by "+++". Following this are one or more change hunks that contain the line differences in the file. The unchanged, contextual lines are preceded by a space character, addition lines are preceded by a plus sign, and deletion lines are preceded by a minus sign.

如果您对两个文件进行过比较,您会看到这样的文件(再次来自维基百科):

--- /path/to/original   ''timestamp''
+++ /path/to/new ''timestamp''
@@ -1,3 +1,9 @@
+This is an important
+notice! It should
+therefore be located at
+the beginning of this
+document!
+
This part of the
document has stayed the
same from version to
@@ -5,16 +11,10 @@
be shown if it doesn't
change. Otherwise, that
would not be helping to
-compress the size of the
-changes.
-
-This paragraph contains
-text that is outdated.
-It will be deleted in the
-near future.
+compress anything.
It is important to spell
-check this dokument. On
+check this document. On
the other hand, a
misspelled word isn't
the end of the world.
@@ -22,3 +22,7 @@
this paragraph needs to
be changed. Things can
be added after it.
+
+This paragraph contains
+important new additions
+to this document.

上面的文件有三个大块头。如果你想查看与提交相关的差异,你可以使用 git show [<commit>] .要查看当前未暂存的更改与存储库之间的差异,您可以使用 git diff .还有其他各种选择。

要计算帅哥的数量(这真的非常没用,但如果你坚持的话),你可以使用一个非常简单的脚本。

git show | grep '^@@.*@@.*$' | wc -l

.* 的原因在第二个之后@@是 git 的 diff 还显示了更改所属的函数,以便稍后可以更好地应用 diff,因此大块标题可能如下所示:

@@ -85,6 +85,6 @@ void urt_shmem_detach(void *mem)

关于git - 与推送 sourcetree 相关的大块头意味着什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17995092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com