Bre*_*ako 22 git atlassian-sourcetree
当我在"develop"分支上进行更改时,我看到分支旁边的向上箭头告诉我将推送多少更改.让您感到困惑的是sourcetree如何决定这个数字是多少?
它似乎与称为帅哥的东西有关?什么是帅哥?
是否存在返回相同数字的等价git提交?
Sha*_*baz 18
请注意,要推送的更改数可能是指您在origin/master之前提交的提交数,与hunks无关.要查看提交您的提交,您可以执行以下操作:
# 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
Run Code Online (Sandbox Code Playgroud)
如果你想数数,只需:
mb=...
git log --pretty=oneline $mb..HEAD | wc -l
Run Code Online (Sandbox Code Playgroud)
hunk是与以下内容相关的术语diff:
格式以与上下文格式相同的两行标题开头,但原始文件前面带有"---",新文件前面带有"+++".在此之后是一个或多个变帅哥包含文件中的行差异.未更改的上下文行前面有空格字符,附加行前面有加号,删除行前面有减号.
如果你曾经拍过两个文件的差异,你会看到这样的文件(再次来自维基百科):
Run Code Online (Sandbox Code Playgroud)--- /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.
上面的文件有三个帅哥.如果要查看与提交关联的diff,可以使用git show [<commit>].要查看当前未暂存的更改与存储库之间的差异,您可以使用git diff.还有其他各种选择.
要计算帅哥的数量(这实际上是无用的,但如果你坚持的话),你可以使用一个非常简单的脚本.
git show | grep '^@@.*@@.*$' | wc -l
Run Code Online (Sandbox Code Playgroud)
.*之后的第二个原因@@是git的diff也显示了更改所属的函数,因此稍后可以更好地应用diff,因此hunk标题可以如下所示:
@@ -85,6 +85,6 @@ void urt_shmem_detach(void *mem)
Run Code Online (Sandbox Code Playgroud)
在回答这个大块头的问题:
Hunk means a piece of change in the Git world.
src:https://mvtechjourney.wordpress.com/2014/08/01/git-stage-hunk-and-discard-hunk-sourcetree/
有建议
用“ change”代替“ hunk”一词,跟随Git变得很愉快。
| 归档时间: |
|
| 查看次数: |
24837 次 |
| 最近记录: |