[英]How to move changes as uncommitted from one branch to another on Git
I want to move all changes that are in a branch relative to master to another branch. 我想将一个分支中的所有更改相对于master移到另一个分支。
I don't want them as commits just as changes so that i can modify them and remove some of the changes and commit as one. 我不希望它们像更改一样作为提交,以便我可以修改它们并删除某些更改并作为一个提交。 I don't want to retain the old committed history. 我不想保留旧的承诺历史。
I tried git format-patch master --stdout > mypatch.path and git apply 我尝试了git format-patch master --stdout> mypatch.path和git apply
but that applies as commits which i can't modify after that. 但这适用于提交,之后我无法修改。
I would do this to move the changes from branch1 to branch2: 我这样做是将更改从branch1移到branch2:
git checkout branch2
git merge --squash branch1
No commit has been created or "copied" between the branches. 分支之间尚未创建或“复制”任何提交。 The changes can be modified before committing if need be. 如果需要,可以在提交之前修改更改。
If I understand what you want to do correctly, one way would be to start with your first branch: 如果我了解您要正确执行的操作,一种方法是从第一个分支开始:
git checkout branch1
Create a new branch from there: 从那里创建一个新分支:
git checkout -b branch2
Reset back to master, which will remove any commits that were made on branch1
, but leave the changes as unstaged: 重置回master,这将删除在branch1
上branch1
所有提交,但将更改保留为未暂存:
git reset master
You can then modify the files further and commit them as one commit. 然后,您可以进一步修改文件并将它们作为一次提交提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.