Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
853 views
in Technique[技术] by (71.8m points)

git - Merge conflicts ruin my commit message while squashing commits

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, you can get the squash commit message back. It's stored in .git/SQUASH_MSG.

You can use it as a template with the following command:

git commit -t .git/SQUASH_MSG

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...