TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Git Rebase and Merge or Squash and Merge?

7 点作者 floriangosse大约 2 个月前
I'd like to know what's your preferred way of merging branches and PRs/MRs.

3 条评论

kcrwfrd_大约 2 个月前
I prefer to update my branch with rebase, and merge it with a squashed merge.
jeremy_k大约 2 个月前
A problem I just ran into with this is that squash and merge obviously loses all the history of the merged branch. If you branched off that branch, when attempting to rebase main, there are a lot of conflicts because all that history is gone. A co-worker suggested cherry-picking commits from the second branch off a clean main as an approach to not dealing with all the conflicts.<p>Example: main -&gt; Branch A -&gt; Lots of commits on A -&gt; Branch B -&gt; Lots of commits on B<p>Now we squash and merge A into main. B now has all of A&#x27;s commit history, plus some of its own, instead of just it&#x27;s own. Rebasing main in causes a lot of conflicts.
评论 #43740976 未加载
评论 #43759658 未加载
ecesena大约 2 个月前
Squash. PR is a github thing, not a git thing (and it’s good imo). In a PR you have description, history, and you accumulate commits as you get review(s). When a PR is ready, all you need is a single commit to main, because the PR itself has the rest of the historic documentation.
评论 #43737654 未加载