[英]Move previous commits to another branch
历史如下:
master branch 1-2-3-4
\
feature branch 5-6-7
我意识到,更改2、3和4也应该已经进入我的功能分支,并希望如下所示移动它们。
master branch 1
\
feature branch 2-3-4-5-6-7
我该怎么办? 没有其他人在使用我的存储库,自创建分支以来,我还没有推送提交,所有更改都已提交。
只需从master删除有问题的提交即可。 它们仍将位于您的功能分支中:
git checkout master
git reset --hard 1 # Replace '1' with the actual SHA for the commit
git push -f origin master # Sync to remote, if applicable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.