[英]How do I transfer changes from one branch to another?
I'm relatively new to GIT, and just made a rather critical error in the source control of my project.我对 GIT 比较陌生,只是在我的项目的源代码控制中犯了一个相当严重的错误。
I've been working on a change for immediate deployment, and just went to push it out to the Master Branch - we're on a relatively small team so the only other branch I'm using is for the release coming after this one.我一直在为立即部署进行更改,并且只是将其推送到主分支 - 我们在一个相对较小的团队中,所以我使用的唯一另一个分支是用于在此之后发布的版本。
When I went to push out my change, I realized that I was still on the branch for the next release.当我去推出我的更改时,我意识到我仍然在分支上等待下一个版本。
I need to push these changes out to our Master branch, and I do not want them to be on this Next Release Branch.我需要将这些更改推送到我们的 Master 分支,并且我不希望它们出现在这个 Next Release 分支上。
Is there any way for me in GIT to move those changes on one branch to a different branch?在 GIT 中我有什么办法可以将一个分支上的这些更改移动到另一个分支?
Alternatively, is there a way for me to safely pull these changes back from being Staged?或者,有没有办法让我安全地将这些更改从暂存状态中撤回?
To get the change included in master:要获得包含在 master 中的更改:
You could git checkout master
, make sure your master is updated ( git pull
or git fetch
and git merge
), and then cherry-pick your commit from the "next release"-branch into master, and finally, git push
master. You could
git checkout master
, make sure your master is updated ( git pull
or git fetch
and git merge
), and then cherry-pick your commit from the "next release"-branch into master, and finally, git push
master.
To revert the change from "next release"-branch:要从“下一个版本”分支恢复更改:
git checkout
the "next release"-branch, git revert HEAD
to undo the last commit (or git revert <hash>
if it's not the last commit), followed by git push
. git checkout
the "next release"-branch, git revert HEAD
to undo the last commit (or git revert <hash>
if it's not the last commit), followed by git push
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.