git - 将 git 历史记录折叠到标签(在标签之间合并提交)
问题描述
我们有一个相当大的(1000 多个提交)存储库,其中包含 7 年的更改和 6 个发布版本(每个版本由一个 git 标签表示)。我们想折叠历史,以便在最后一个标签之前,两个标签之间的所有提交都折叠成一个提交,带有版本标签。从而将我们的存储库历史记录减少到大约 15 次提交。我们不会跨版本进行任何还原。作为奖励,理想情况下,我们希望将所有提交我们崩溃的人保留为co-authored-by
. 如果它很重要,我们没有任何从标签之前跳过标签进入新版本的合并。
从:
CHEAD
C2
C3
...
TAG6
Cx
Cy
...
TAG5
Ca
..
进入
CHEAD
C2
C3
...
TAG6
TAG5
TAG4
TAG3
TAG2
TAG1
关于如何进行的任何想法?
解决方案
按标签折叠很容易:git log
有两个选项--simplify-by-decoration
和--decorate-refs=<pattern>
,您可以按如下方式使用:
# --graph is useful to have a clear view of parent <-> child relation,
# you may use --oneline to have a compact view, or drop it if you want the complete
# commit messages
git log --graph --oneline --simplify-by-decoration \
--decorate-refs=refs/tags # <- this indicates 'keep only tags'
获得“之后的所有内容TAG6
,只有之前的标签TAG6
”的一种部分方法可能是在两个命令中获取日志:
# in a 'mylog' script :
#!/bin/bash
log_history () {
# get all from TAG6 up to HEAD :
git log --decorate --graph TAG6..HEAD
# get only tags up to TAG6 :
git log --decorate --graph --simplify-by-decoration \
--decorate-refs=refs/tags TAG6
}
# combine the two commands, and pipe them in your pager
# if you pipe the output of 'git log', git removes the default '--decorate',
# that's why I added it in the commands above
log_history | less
以上将为您提供您想要查看的提交的完整列表;唯一缺少的部分是,在图中,不会绘制TAG6
与其子提交(上面的提交)之间的链接。TAG6
我不知道如何指示您在一个git log
命令中描述的组合。
推荐阅读
- dart - 如何使用 dart/flutter 在不同的类上使用变量
- tabs - 如何创建多个终端选项卡并使用 shell 脚本为每个选项卡命名
- android - 在 MVP 模型的构造函数参数中包含 Context 是一种不好的做法吗?
- c# - SignalR Core 中默认对所有集线器进行授权
- python - urlopen中的url.request奇怪的行为python3
- ruby-on-rails - 为什么 ldap 绑定在服务器上失败?
- angular - 管理用户 - Firebase 和 Angular
- android - 通过点击推送消息打开 Xamarin.Forms Android 应用程序时挂起
- android - 错误重复 jar 条目 [android/support/v4/media/MediaBrowserCompat$a.class]
- ios - 选择时更改单元格视图颜色。并在选择另一个单元格时将其更改回来