如何使用新的提交对象将分支与 Magit 合并?

发布于 2024-09-03 00:06:20 字数 196 浏览 2 评论 0原文

如果不将它们一致地压缩到当前分支中,我似乎无法使用 Magit for Emacs 完整地进行合并。有时合并后会创建一个新的提交对象(这就是我想要的),有时提交会被压缩。

我基本上只想在 Magit 中执行“git merge --no-ff topicbranch”。

那么如何使用 Magit 强制执行 --no-ff 标志/创建新对象规则?

I can’t seem to get my merges intact with Magit for Emacs without squashing them into the current branch consistently. Sometimes a new commit object is created after the merge (which is what I want), sometimes commits are squashed.

I basically just want to do 'git merge --no-ff topicbranch' in Magit.

So how do I enforce the --no-ff flag/create new object rule with Magit?

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

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

发布评论

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

评论(1

太阳哥哥 2024-09-10 00:06:20

也许是因为该补丁已包含在当前的 Magit 中?

(defun magit-manual-merge (rev)
-  (interactive (list (magit-read-rev "Manually merge" (magit-guess-branch))))
+  (interactive (list (magit-read-rev (concat "Manually merge"
+                                             (if current-prefix-arg " (squashed)" ""))
+                                     (magit-guess-branch))))
   (if rev
-      (magit-run-git "merge" "--no-ff" "--no-commit"
+      (magit-run-git "merge" "--no-commit" (if current-prefix-arg "--squash" "--no-ff")
             (magit-rev-to-git rev))))

如果您想压缩合并(让 git 避免创建合并提交),请在命令中使用前缀参数 (@kbd{CU m})

您是否使用前缀参数?

Maybe because that patch has be included in the current Magit?

(defun magit-manual-merge (rev)
-  (interactive (list (magit-read-rev "Manually merge" (magit-guess-branch))))
+  (interactive (list (magit-read-rev (concat "Manually merge"
+                                             (if current-prefix-arg " (squashed)" ""))
+                                     (magit-guess-branch))))
   (if rev
-      (magit-run-git "merge" "--no-ff" "--no-commit"
+      (magit-run-git "merge" "--no-commit" (if current-prefix-arg "--squash" "--no-ff")
             (magit-rev-to-git rev))))

If you would like to squash the merge (have git avoid creating a merge commit) then use a prefix argument with the command (@kbd{C-U m})

Are you using a prefix argument?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文