Skip to content

Instantly share code, notes, and snippets.

@LeoCavaille
Last active June 23, 2020 09:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save LeoCavaille/2403bcdf6d088a45cfb9 to your computer and use it in GitHub Desktop.
Save LeoCavaille/2403bcdf6d088a45cfb9 to your computer and use it in GitHub Desktop.
How to properly rebase and deal with a contributor's PR
[alias]
checkoutpr = "!f() { git fetch origin refs/pull/$1/head:pr/$1; git checkout pr/$1; } ; f"
checkoutcontrib = "!f() { git checkout master && git pull && git remote add $1 git@github.com:$1/dd-agent && git fetch $1 $2 && git checkout -b $3 $1/$2 && git rebase master } ; f"
# First of course clear your staging area and stash your mess
# Forked and PR'd from contributor:mysuperfeature
git checkoutcontrib contributor mysuperfeature leo/rebasedsuperfeaturebranch
# OK it's rebased I can do my mods
git rebase -i master
# Include a message in the commit if you're commiting someone else's work
# For example:
# [leo@datadoghq.com] rebased current work to get new feature and minor
# cosmetic changes
# Or add more work
git commit -m "Some work"
git push origin leo/rebasedsuperfeaturebranch
# Create a new PR with this branch
# Close the other one
# Don't forget to thank the contributor!
# If you want just to checkout one PR's code to play with it locally
# Get the PR number, return in a clean state and run for PR 23432
git checkoutpr 23432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment