简体   繁体   中英

rebase a PR to a single commit on top of master

I'm new to Git and GitHub. I created a PR to a repo after which I had done a few more edits in the PR. "5 out of 6 commits in this PR are merged commits or fixup commits. Could you please rebase this PR to a single commit on top of the master?" I was asked by the repo maintainer to do this but I don't really know how to do convert all those 6 commits in a PR into a single commit on top of the master and what's the meaning of "commit on top of the master"?

I don't know the details about how you laid out the history of your work but, assuming that the differences between the branch you started from and your branch are the work that you need to commit and only that, what I would do is: I would find out the last revision that both your branch and the "master" share in common and then I would create a single revision with all the differences from that point. Adjust to your convenience:

git checkout my-branch
git merge-base my-branch origin/master # this will output a revision ID
git reset --soft the-id-provided-before # set branch pointer on that revision
git commit -m "This is my work in a single revision"
git push whatever-repo my-branch

Then you could create the PR from that revision after "cleaning up" and creating a single revision.

Looking into the future, I'd tell you to learn how to use rebase and cherry-pick to avoid merges if you plan to share your work with other people.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM