我需要从我的主分支推出一些更改,但不需要已经在那里的几个提交。
如果我使用当前的更改从'master‘分支,然后返回到'master’并恢复到以前的提交。在git-revert之前,我的分支会保持和'master‘一样吗?
在我的脑海中,我觉得这将允许我改变'master',推出一个版本,然后从我之前创建的分支中挑选其他的提交回到'master‘上。
我能这么做吗?
发布于 2013-06-28 17:17:21
git checkout master # switch to master
git branch branchname # create a new branch with the changes from master
git reset --hard commitname #reset the master back.这会让你的主控器通过一些提交来后退。
但你确定你不想
git checkout REVISION # set the working dir to another commit.更改已经发布的分支的历史记录不是一个好主意。只需解开工作树中的更改,就可以得到您想要的提交,而不会实际更改其他人的视图。这称为分离头模式。更深入的解释可以在here找到
https://stackoverflow.com/questions/17361202
复制相似问题