GitHub Pull Request for a Single Commit

Sometimes you want to create a pull request for a single commit in a fork rather than for all the differences to the main repository. Unfortunately the GitHub pull request interface doesn’t support this. There is a pretty easy workaround though by creating an additional branch and cherry picking the commit(s) you wan’t to send a pull request for.

First create an empty branch using the SHA of the last commit when your fork was still in sync. You can find this SHA easily by trying to create a pull request for your fork and selecting the SHA of the oldest commit:

git checkout -b feature 1fe4892^1

Next sync with the main repository:

git pull official master

Cherry pick the commit(s) you want to send a pull request for:

git cherry-pick 5e99125

Push the new branch to GitHub:

git push origin feature

After this is done you can select the newly pushed branch from the “compare” dropdown when creating the pull request.

If you want to clean up after the pull request has been accepted you can simply run these 3 commands remove the temporary branches locally and remotely:

git checkout master
git -D feature
git push origin :feature
GitHub Pull Request for a Single Commit

Using vimdiff as GIT diff tool

If you want to review and edit your currently pending changeset in GIT vimdiff can be very handy. The regular git diff will simply output differences in patch format. If you set up GIT to use vimdiff as diff tool you will be able to see the differences in VIM’s split window view and be able to edit them too.

To use vimdiff as GIT diff tool simply run those 3 commands:

# git config --global diff.tool vimdiff
# git config --global difftool.prompt false
# git config --global alias.d difftool

Alternatively you can add these 3 sections to your .gitconfig

    tool = vimdiff
    prompt = false
    d = difftool

If you now run git d [file] you will see the changes in VIM. You can still use the regular git diff command to get the patch output.

Using vimdiff as GIT diff tool