Skip to content

Instantly share code, notes, and snippets.

@yannvery
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save yannvery/995d73f74cc98f4ddb1d to your computer and use it in GitHub Desktop.

Select an option

Save yannvery/995d73f74cc98f4ddb1d to your computer and use it in GitHub Desktop.
How to pull request

#How to make a pull request

First steps

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Squashing

Sometimes you'll make more commits than you really need to. If the maintener wants a single commit for your request : squash it

Rebase to master

git rebase -i origin/master

This will open your editor with these contents:

pick f33b240 Hack hack
pick 73bbc09 Hack some more
pick 73bbc99 Hack again
# Rebase e54a9a9..73bbc99 onto e54a9a9
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell

Keep the first line unchanged and for the two lasts commits change 'pick' by 'squash' and save.

You'll then get another editor with a commit message to edit:

# This is a combination of 3 commits.
# The first commit's message is:

Hack hack

# This is the 2nd commit message:

Hack some more

# This is the 3st commit message:

Hack again

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# ...

Remove all content of this file and add you uniq commit message, save and exit. All your commits are merged on one commit.

Make a git log if you want to check results.

Push

Now push on your fork repo with --force option :

git push --force origin my-new-feature

or

git push origin +master my-new-feature


Note that `--force` may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). 
To force a push to only one branch, use a '+' in front of the refspec to push 
(e.g git push origin +master to force a push to the master branch).

Your pull request will be automatically updated.

Reference : squashing-github-pull-requests-into-a-single-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment