我有一个本地分支,我们使用git-flow和Pull Requests,我想在收到PR反馈后压缩一些提交。
我应该如何将所有提交(例如来自PR的提交)压缩到同一分支中?
我想应该是这样:
git checkout master # For master
git pull # Get all branches up-to-date
git checkout feature1 # Checkout the branch
git checkout -b feature1_squash # Make a copy of the branch
git branch -D feature1 # Delete original branch
git checkout master # (?) Branch off latest master for safety
git checkout -b feature1 # Make new (empty) original branch
git merge --squash feature1_squash # Merge with squash into it
git push -f feature1 # Push, force will be required
但我不确定。
有这么多步骤,使用一个函数将所有内容绑在一起,并只传递分支名称作为参数似乎是一个不错的选择。当然,自动化意味着要确保处理错误、异常、边缘情况等。
我不想使用交互式变基,因为对于我培训的新手来说,这有点棘手。我也不想知道提交的数量,我只想做这个分支上存在的所有提交。