[英]Git rollback a branch to a previous commit while keeping master branch where it's at (and PR that branch?)
I'm doing some contributing on an open source project on github.我正在为 github 上的开源项目做一些贡献。 The repo owner said he would prefer separate PR's for the things I'm working on.回购所有者说他更喜欢单独的 PR 来处理我正在做的事情。 However, I had already started working on the next issue on the master branch.但是,我已经开始在 master 分支上处理下一个问题。
So I'd like to open up a new branch, roll back that branch to where the first issue was fixed, and push that branch as a PR.所以我想打开一个新分支,将该分支回滚到第一个问题已修复的位置,并将该分支作为 PR 推送。
How can I do this?我怎样才能做到这一点?
By rebasing... and I understand you are working on master?通过变基......我知道你正在研究主人?
# let's create the new branch
git branch second master # right where your master is right now
# now let's put master where you really want it to be now
git checkout master
# if you have stuff laying around, stash it before running the next command
git reset --hard revision-where-you-want-it
# now you can force-push master so your previous PR only holds this in
# rebasing second
git rebase --onto orign/master master second # move only revisions past master
And you are done.你完成了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.