Git Squash by author - All author commits into a single commit

后端 未结 3 1622
鱼传尺愫
鱼传尺愫 2020-12-19 05:31

I am trying squash many commits into a single one, the problem is that I need do that by author (name or email).

The case:

Lets say I have a branch called fe

3条回答
  •  醉酒成梦
    2020-12-19 06:25

    With Kenkron's caveats in mind, you could do a:

    SORTED_GIT_LOGS=$(git log --pretty="format:%an %H" master..feature_a | sort -g | cut -d' ' -f2); \
    IFS=$(echo -en "\n\b"); for LOG in $SORTED_GIT_LOGS; do \
        git cherry-pick $LOG; \
    done | less
    

    The git log --pretty="format:%an %H" master..feature_a | sort -g would sort the logs of the feature_a commits (not the ones from master because of the master..feature_a syntax)

    You would still need to do an interactive rebase to squash the (now ordered by author) commits on master.

提交回复
热议问题