Shing Lyu: Beginner's guide to git rebasing and squashing |
I wrote this post on the Servo wiki to help beginners getting started with rebasing and squashing, two of the most terrifying operations you’ll face if you are not familiar with git. I’m cross posting this here for people working on other projects.
Big thanks to Wafflespeanut who proofread the post, any error you found here is my own.
Suppose you’ve created a pull request following the checklist, but the reviewer ask you to fix something, do a rebase or squash your commits, how exactly do you do that? If you have some experience with git, you might want to check the GitHub workflow for a quick overview. But if you are not familiar with git enough, we’ll teach you how to do these common operations in detail.
Suppose you’ve created a pull request following the checklist, but the reviewer asks you to fix something, do a rebase or squash your commits, how exactly do you do that? If you have some experience with git, you might want to check the GitHub workflow for a quick overview. But if you are not familiar with git enough, we’ll teach you how to do these common operations in detail.
Once you reviewer reviewed your patch, he/she might leave some comments asking you to fix something. So you edit the source code, then you will probably do something like this.
git add
then git commit
, write a commit message telling people what you’ve fixed. (You might also check out the --fixup
option for git commit
in the workflow doc.)git push
to the same remote branch which you’ve created the PR with. The GitHub pull request page will pick up your changes, and hide those review comments you’ve fixed.If your fix is trivial, and you have a single commit ready for merge, then you can consider using git commit --amend
to add the change directly to your last commit. Then, all you need to do is git push -f
to force push to the branch at your fork.
Sometimes, if someone merged new code while your patch is still in review, git might not be able to figure out how to apply your patch on top of the new code. In this case, our bors-servo bot will notify you with a helpful message:
https://shinglyu.github.io/web/2016/11/08/servo-rebase-and-squash-guide.html
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |