| title | Pretend You Kept Your Copy of Push Updated |
|---|---|
| layout | learn |
| id | learn_git_rebase |
Once you create a separate branch, such as submission, to work, it too will fall out of sync
with the master branch off of the upstream Push repository at cwcon/push.
To make a cleaner pull request, it’s helpful if you rebase the branch you wish to submit to Push.
Rebasing essentially takes the commits from another branch (such as master), and puts your commits
at the very end of that branch. On GitHub and elsewhere, it will appear as though you built your
work on top of the very latest changes to Push.
Please do not rebase after you have submitted a pull request.
Do this each time you need to rebase
-
Be sure that you have updated your
masterbranch to match the latestmasterat the upstream Push repository. -
Once you’ve done that, check out your submission branch, and rebase it with the
masterbranch:$ git checkout submission $ git rebase master First, rewinding head to replay your work on top of it... Applying: Starting a new submissionIn that example, a commit called “Starting a new submission” was applied after the end of the rebase.
-
Important: Once you rebase, your commits receive new SHA-1 hashes. This can confuse GitHub, and when you go to push a rebased branch, GitHub will likely refuse to accept it. You need to force GitHub to accept your rebased branch, using the -f flag:
$ git push -f origin submission