Merge conflicts ruin my commit message while squashing commits

后端 未结 3 1343
难免孤独
难免孤独 2020-12-13 16:19

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

相关标签:
3条回答
  • 2020-12-13 16:30

    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
    
    0 讨论(0)
  • 2020-12-13 16:39

    Nothing is really lost with git. The list of the commits on the feature branch can be obtained using:

    git cherry feature-branch
    

    Then simply pipe this to git cat-file:

    git cherry feature-branch | cut -f2 -d' ' | git cat-file --batch
    

    You need to clean-up the output though. I don't know a way to automated it better.

    0 讨论(0)
  • 2020-12-13 16:42

    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?

    0 讨论(0)
提交回复
热议问题