简体   繁体   English

Git 将分支回滚到上一个提交,同时将主分支保持在它所在的位置(以及 PR 那个分支?)

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

相关问题 Git回滚/删除PR中的推送分支 - Git rollback/delete of pushed branch in PR 将 master 分支重置为初始提交但保留以前的历史记录 - Resetting master branch to initial commit but keeping previous history 将 git 中的分支恢复为同一分支中的先前提交 - revert the branch in a git to the previous commit in the same branch Git:在Github上做一个分支作为主人,同时在BitBucket上保持真正的主人 - Git: make a branch as master on Github while keeping real master on BitBucket 如何在保留原始提交历史记录的同时将分支重新建立为master? - How to rebase a branch to master while keeping the original commit history? 将所有更改提交到临时分支,同时在 master 上保持未提交 - Commit all changes to temporary branch while keeping them uncommited on master Git将master分支回滚到master的历史记录中的特定提交 - Git rewind master branch to specific commit in master's history 如何合并 git 中的分支,该分支一直在 master 中删除文件,同时在 master 分支中保持删除的文件完整? - How to merge branch in git which deleted files in master all the while keeping the deleted files intact in the master branch? git svn master to branch to master - 仍然尝试提交到分支 - git svn master to branch to master - still tries to commit to branch 我可以在首次提交之前创建分支,同时保持master分支完整吗? - Can I create branch before first commit while keeping master branch intact?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM