Merge GIT branch without commit log

后端 未结 3 1583
栀梦
栀梦 2020-12-23 09:48

Currently when I\'m using GIT I create a branch for each job and make various commits before I\'m finished. I then merge back with my master branch and push upstream. I\'m l

3条回答
  •  不思量自难忘°
    2020-12-23 10:10

    As mentioned in "Trimming GIT Checkins/Squashing GIT History", if your commits c and e were done with a comment prefixed with fixup!, then the rebase --interactive --autosquash (git1.7+, February 2010) can do exactly what you are after.

    with the fixup! directive, you could keep that squashing "invisible" in the commit message, while still benefiting from the automatic commit reordering with the --autosquash option.

    To commit with a fixup! prefix, you can define the alias

    [alias]
        fixup = !sh -c 'git commit -m \"fixup! $(git log -1 --format='\\''%s'\\'' $@)\"' -
        squash = !sh -c 'git commit -m \"squash! $(git log -1 --format='\\''%s'\\'' $@)\"' -
    

    The fixup alias would then apply for those "commits (which) are just save points, i.e. not that important in the grand scheme of things".

提交回复
热议问题