在压缩提交时合并冲突会毁掉我的提交消息 [英] Merge conflicts ruin my commit message while squashing commits

查看:120
本文介绍了在压缩提交时合并冲突会毁掉我的提交消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用git的工作流程是创建一个新的特性分支,用频繁的提交做一些工作,然后在特性工作和/或稳定时重新合并到开发分支。通常,当我做 git merge --squash feature-branch 时,我得到一个很好的压扁的提交以下消息自动填充来自功能分支的所有提交消息。然而,如果存在任何合并冲突(比如说完成并合并了另一个特性),我似乎失去了来自分支的所有提交消息。自动填充的提交消息填充冲突,但不填充提交消息。我的提交信息去了哪里?我不能直接回答你的问题,但是你应该能够避免冲突。我可以让他们回来吗?

解决方案

第一个地方。



考虑做一个

  git rebase主题

在执行合并之前。本页的DESCTIPTION部分 http://git-scm.com/docs/git-rebase 应该是有帮助的。这也可以避免对壁球的需求,因为交互式底牌可以让您压缩您所选择的提交。



编辑:
另请参阅:在git中,什么是merge --squash和rebase之间的区别?


My usual workflow with git is to create a new feature branch, do some work with frequent commits, and then merge back into the development branch when the feature is working and/or stable.

Usually, when I do git merge --squash feature-branch, I get a nice "squashed commit of the following" message that auto-populates with all of the commit messages from the feature branch.

However, if there are any merge conflicts (say I finished and merged another feature while working on this one), I seem to lose all of my commit messages from the branch. The auto-populated commit message fills in the conflicts, but not the commit messages. Where did my commit messages go? Can I get them back?

解决方案

This doesn't answer your question directly, but you should be able to avoid the conflict in the first place.

Consider doing a

git rebase master topic

before performing the merge. The DESCTIPTION section of this page http://git-scm.com/docs/git-rebase should be helpful.This may also obviate the need for the squash as an interactive rebase would allow you to to squash commits of your choosing.

EDIT: See also: In git, what is the difference between merge --squash and rebase?

这篇关于在压缩提交时合并冲突会毁掉我的提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆