简体   繁体   English

如何将更改从一个分支转移到另一个分支?

[英]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.

相关问题 如果文件名更改,如何将更改从一个分支转移到另一个分支? - How to transfer changes from one branch to another if file name changed? 如何在 git 中不将对文件所做的更改从一个分支转移到另一个分支 - How do I not transfer changes done to files from a branch to a another in git 将更改从一个提交的分支转移到另一个分支 - Transfer changes from one committed branch to another branch GIT:如何从一个分支还原一个分支的所有更改 - GIT: How Do I Revert All The Changes Of One Branch From Another Branch 如何确定一个分支中的哪些更改不属于另一个分支? - How do I determine which changes in one branch are missing from another? 将一个分支的无阶段变更转移到另一个分支 - transfer unstaged changes of one branch into another 如何将更改从一个分支推送到另一个分支? - How to push changes from one branch to another? 在git中将更改从一个分支更改为另一个分支,以及如何在自己的分支上工作 - Get changes from one branch into another one in git and how can I work on my own branch 使用git,如何将一些未提交的更改从一个分支移动到另一个文件夹中的另一个分支? - Using git, how do you move some uncommitted changes from one branch to another branch in a different folder? 如何通过git将更改从一个分支拉到另一个分支 - How to pull changes from one branch to another branch through git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM