Forked from nickboldt/git workflow - applying a PR
Created
November 14, 2012 10:31
-
-
Save maxandersen/4071430 to your computer and use it in GitHub Desktop.
git workflow - applying a PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First, add this to your .gitconfig file: | |
[alias] | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %C(blue)%aE%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative | |
-------------------- | |
# applying a PR | |
PR_USER=dgolovin | |
PR_REPO=git://github.com/dgolovin/jbosstools-server.git | |
PR_TOPIC=jbide-1234 | |
MY_TOPIC=${PRTOPIC} | |
ORIGIN_BRANCH=master | |
Step 1: Create a topic branch for you to inspect the PR | |
(make sure you are on the right branch you want to apply this to eventually, i.e. git checkout master) | |
$ git checkout -b ${MY_TOPIC} | |
Step 2: Get the actual PR repo/branch into your local reposiory | |
$ git pull ${PR_REPO} ${PR_TOPIC} | |
Step 3: Inspect the commits / test the code. | |
Look at log: | |
$ git lg | |
Look at the commits/test the code. Does it look right, i.e. even worth merging ? | |
If not reject and stop. | |
If yes, continue. | |
Step 4: Make sure you are uptodate with original repo branch. | |
$ git fetch orgin ${ORIGIN_BRANCH} | |
Step 5: rebase against it | |
$ git rebase origin ${ORIGIN_BRANCH} | |
Step 6: check log. | |
$ git lg | |
Step 7: check the code is still working (i.e. if additional commits things might not be as you expect) | |
Good time now to check if any surprises found in the diff. | |
$ git diff origin/${ORIGIN_BRANCH} | |
Step 8: Everything ok ? Goto origin, pull in the changes. | |
$ git checkout origin/${ORIGIN_BRANCH} | |
$ git merge ${MY_TOPIC} | |
$ git lg | |
Step 9: everything still fine ? Push it | |
$ git push origin ${ORIGIN_BRANCH} | |
(if something errors most likely someone committed in the mean time OR you messed up the history somehow...don't push force! Fix the history then :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment