不rebase生成单个commit的trick方法,命令如下:

# 比如:branch名为xxx
# 操作步骤:
git checkout master
git pull
git checkout xxx
git pull
git merge master
git diff master xxx > patch.xxx
git checkout master
patch -p1 < patch.xxx
git add ***
git ci -m "message"

写了个脚本,仅供参考:

BRANCH_NAME="your_branch_name"
git checkout master
git pull
git checkout $BRANCH_NAME
git pull
git merge master
git diff master $BRANCH_NAME > patch.txt
git checkout master
patch -p1 < patch.txt
git commit -a -m "$BRANCH_NAME"
git push