-
Notifications
You must be signed in to change notification settings - Fork 19
Git: Rebasing commits
My pull request was squashed and accepted to the public repository. I now have a new set of commits that I would like to upload, but I need my branch to reflect the squash before I can have it accepted
If you are using Cygwin, please fix VIM with the commands in the "Fix VIM in Cygwin" page of this wiki.
git fetch --all
git checkout master
git branch -D upstream_following
git branch upstream_following upstream/master
git rebase -i upstream_following
This will open a text editing environment with the list of commits that differ from the upstream_following branch. The goal here to solve the problem is to "drop" the commits that have been squashed, and leave "pick" for the ones that you would like to make into a new pull request.
Stack the new commits on the upstream_following branch:
- Press "i" to start inserting text
- The commits are listed earliest to latest. Delete "pick" from the first line, and replace with "drop." Repeat for all of the commits that were squashed. Leave the ones you want to add to upstream.
- Press escape to exit INSERT mode
- ":wq" and ENTER to save this file
The rebase will now do its work. It's using the upstream_following branch as the new base for your master branch.