如何获得在分支上以及仅在GIT中的分支上进行的更改?

发布于 2025-02-02 19:45:45 字数 326 浏览 2 评论 0原文

假设我有以下分支机构,

    B---C---D---E---F---G       feature
   /           /         \
--A---F---G---H----I------J     master

有一个功能分支,通过合并主人的功能(Merge Consits B和E)会定期从主人那里刷新。当功能准备就绪时,它将合并到主(Merge Commit j)中,因此此时功能和主体是等效的。

我想查看或记录仅在功能分支上更改的内容,而无需合并提交(B和E)。因此,有什么办法可以在功能分支合并上查看更改。

谢谢。

Let's say, I have the following branches

    B---C---D---E---F---G       feature
   /           /         \
--A---F---G---H----I------J     master

There's a feature branch which is periodically refreshed from master by merging master to feature (merge commits B and E). And when feature is ready it is merged into master (merge commit J), so at this point feature and master is equivalent.

I'd like to view or log what has changed only on feature branch without merge commits(B and E). So is there any way that I can view the changes only on feature branch combined.

Thanks.

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

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

发布评论

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

评论(1

北笙凉宸 2025-02-09 19:45:45
git log --first-parent --no-merges A..feature

有了您想要的任何详细信息,也许- oneline-patch

AFAIK没有便利命令在这里找到a,这是第一个父母合并基础,这是两个提示的第一父母的祖先中的最新提交,但这很容易做到:

merge-base-first-parent() {
        ( git rev-list --first-parent $1;
          git rev-list --first-parent $2
        ) | awk 'seen[$1]++{print $1;exit}'
}

git log --first-parent --no-merges --oneline --patch \
        $(merge-base-first-parent master feature)..feature

在您的悠久历史上, Rev-List的- 父母以及对堕落案例的特殊处理,可以使其始终快速运行。

要将更改视为单个差异,您必须在没有合并的情况下构造尖端的外观。这很容易做到,你可以

git checkout A
git rev-list --reverse --no-merges A..feature | git cherry-pick -n --stdin
git diff @
git log --first-parent --no-merges A..feature

with any details you want, maybe --oneline --patch.

There's afaik no convenience command to find A here, the first-parent merge base, the most recent commit in two tips' first-parent ancestries, but it's pretty easy to do:

merge-base-first-parent() {
        ( git rev-list --first-parent $1;
          git rev-list --first-parent $2
        ) | awk 'seen[$1]++{print $1;exit}'
}

git log --first-parent --no-merges --oneline --patch \
        $(merge-base-first-parent master feature)..feature

and in really long histories you can get cute with rev-list's --parents and special handling for the degenerate cases to make it always run quick.

To view the changes as a single diff, you'll have to construct what the tip would look like without the merges. That's easy enough to do, you can

git checkout A
git rev-list --reverse --no-merges A..feature | git cherry-pick -n --stdin
git diff @
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文