提问人:Raedwald 提问时间:2/24/2017 更新时间:2/7/2023 访问量:2365
什么是 git 边界提交
What is a git boundary commit
答:
4赞
CodeWizard
2/24/2017
#1
--boundary
--boundary
参数是显示 commit(parent revision) 的上下文。
边界提交是不属于执行命令的“框架”的提交。(--since、提交范围等)
例如,如果使用类似 的参数,则三周前的提交将被视为边界提交
。通常提交用–since=3.weeks
boundary
-
您可以在上面的屏幕截图中看到,在第二个日志中,最后一次提交已“消失”。这是由于旗帜--boundary
您可以看到提交前有一个符号,而不是常规提交中的 as。o
*
14赞
Leon
2/24/2017
#2
边界提交是限制修订范围但不属于该范围的提交。例如,修订范围由 3 个提交(、 和 )组成,提交用作它的边界提交。HEAD~3..HEAD
HEAD~2
HEAD~1
HEAD
HEAD~3
更正式地说,git 通过从指定的提交开始并通过父链接获取其他提交来处理修订范围。它停止在不符合选择标准(因此应排除)的提交上 - 这些是边界提交。
插图:
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in ~/playground/git/test/.git/
$ touch a
$ git add a
$ for i in {1..5}; do echo $i >> a; git commit -m "Commit #$i" a; done
[master (root-commit) bf958f1] Commit #1
1 file changed, 1 insertion(+)
create mode 100644 a
[master 3721a8b] Commit #2
1 file changed, 1 insertion(+)
[master d69efcc] Commit #3
1 file changed, 1 insertion(+)
[master 72cd21d] Commit #4
1 file changed, 1 insertion(+)
[master 17ae9c3] Commit #5
1 file changed, 1 insertion(+)
$ git log --oneline
17ae9c3 Commit #5
72cd21d Commit #4
d69efcc Commit #3
3721a8b Commit #2
bf958f1 Commit #1
$ git log --oneline HEAD~3..
17ae9c3 Commit #5
72cd21d Commit #4
d69efcc Commit #3
$ git log --oneline HEAD~3.. --boundary
17ae9c3 Commit #5
72cd21d Commit #4
d69efcc Commit #3
- 3721a8b Commit #2 <-- This is the boundary commit HEAD~3 that would
not be included in the output had the '--boundary'
option NOT been provided
评论
0赞
torek
2/25/2017
有趣的是,当进行复杂的修订遍历时,例如在任一分支上执行所有提交,但不在两个分支上执行所有提交,您可能希望边界提交仅限于合并基,但事实并非如此:您可以获得“偏离”的非合并基边界,其中两个深度优先的遍历“冲突”。我不认为人们应该指望这一点,因为图形行走算法可能随时更改以提高速度,这可能会产生或多或少的边界。幸运的是,对于简单的排除项 (),只有一个边界。br1...br2
reject..include
0赞
LeGEC
2/7/2023
很好的解释。值得一提的是,正如 @CodeWizard 在他的回答中所说,“边界提交”可以从许多过滤标准中出现:、 和其他一些标准——这个概念并不局限于“一个单一范围的提交的边界--since
--[no-]merges
--first-parent
a..b
"
1赞
LeGEC
2/7/2023
#3
我有一个具体的例子,说明我什么时候想看到一个边界提交:
比较两个不同分支中的提交的一种方法是查看两个分支的对称差异:
# for example: see the commits of a branch with respect to the commits in its upstream:
git log --graph --oneline <branch>...<branch>@{u}
上述命令的一个问题是:由于“对称差异”不包括两个分支之间的公共基数,因此输出是提交的线性序列:
* (branch) local commit 3
* local commit 2
* local commit 1
* (origin/branch) remote commit 2
* remote commit 1
一个更好的(恕我直言)视图是绘制相同的图形,同时包含公共合并基础。这可以通过添加以下内容来完成:--boundary
$ git log --boundary --graph --oneline <branch>...<branch>@{u}
* (branch) local commit 3
* local commit 2
* local commit 1
| * (origin/branch) remote commit 2
| * remote commit 1
|/
o last common commit
在其他一些视图中,您可能还会有一个更好的图形,例如分支分叉的视图提交:
# will not show the history of 'master',
# but will show the commit on 'master' from which each branch starts
git log --graph --oneline --boundary ^master feature1 feature2 feature2
上一个:EJB 有什么用
评论