要保留分支提交,但将分支从主分支重置,可以使用以下代码示例:
git checkout main
git pull origin main
git checkout branch_name
git rebase main
git add .
git rebase --continue
git push origin branch_name --force
注意:使用--force
选项强制推送,因为我们改变了分支的历史。
这些步骤将保留分支的提交,但将分支重置为主分支的最新提交。
上一篇:保留分页的最佳方法在编辑记录后