Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Merging Pull Requests

Xin Zhang edited this page Jan 14, 2016 · 10 revisions

Avoiding introducing non-linear Merge Commits:

Heikki's email (@hlinnaka)

To be clear though: please try to avoid introducing merge commits like this! Always rebase your patches over current master before pushing. I never do "git pull" myself, I always use "git pull --rebase", which avoids merge commits.

Also, before pushing, always do "git push --dry-run" first. It will print out something like:

 To git@github.com:hlinnaka/gpdb.git
    f902442..348f3e8  master -> master

Copy-paste the commit ids, and have one last look at what you're about to push:

git log f902442..348f3e8

Check that there are no merge commits. You can also do -p or --stat to show more details of what you're about to push.

Follow on note from Daniel Gustafsson(danielgustafsson) to change the default git pull operation:

This can also be set as the default by adding "rebase = true” under the [pull] section of .gitconfig.

An example of format of the comment in merge

Please amend the comment in the merge to automate the github process, e.g., close the PR as soon as the merge finished, etc. For example, this commit 7c0dd:

Bump GPOPT version to 1.617
Fall back to legacy query optimizer for queries with partition elimination over full outer join queries.

Closes #265

The last line "Closes #265" indicate to github that this commit will automatically close PR #265.

An example of doing linear merge of pull request (PR) from contributor

Using PR#268 as an example:

# create a working directory
mkdir pr
cd pr

# clone the GPDB repo
git clone git@github.com:greenplum-db/gpdb.git .

# add remote github pull request
git fetch origin pull/268/head:pr268

# rebase the PR to latest of master
git checkout pr268
git rebase master

# forward only merge the local branch
# if found merge conflict, comment in PR to solve the conflict, then restart.
git checkout master
git merge --ff-only pr268

# dry-run a push, and make sure no merge conflict
git push --dry-run origin master

# Example output:
# To git@github.com:greenplum-db/gpdb.git
#   4a1ec1b..b03d961  master -> master
git log 4a1ec1b..b03d961

# finally push the change back
git push origin master

# cleanup the working directory
cd ..
rm -fr pr

At the end, you should see a linear commit history.