Created
November 9, 2012 19:12
-
-
Save nickboldt/4047607 to your computer and use it in GitHub Desktop.
git workflow - submitting a PR
This file contains 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 | |
Next, ensure you have the correct remotes configured for your local repo, eg. one for every user from which you'll pull a PR, and an origin: | |
$➔ git remote -v | |
${GITUSER} git@github.com:nickboldt/jbosstools-build.git (fetch) | |
${GITUSER} git@github.com:nickboldt/jbosstools-build.git (push) | |
origin git@github.com:jbosstools/jbosstools-build.git (fetch) | |
origin git@github.com:jbosstools/jbosstools-build.git (push) | |
(Add more remotes with `git remote add <name> <URL>`) | |
Finally, consider installing hub: https://github.com/defunkt/hub#readme | |
-------------------- | |
# doing work & submitting a PR | |
GITUSER=nickboldt | |
TOPIC=JBIDE-12853-Beta2x | |
BRANCH=jbosstools-4.0.0.Beta2x | |
TOPIC=JBIDE-12853-master | |
BRANCH=master | |
echo $BRANCH, $TOPIC | |
git pull origin ${BRANCH} | |
git checkout ${BRANCH} | |
git checkout -b ${TOPIC}; git checkout ${TOPIC}; git branch -v | |
# * edit, commit, edit, commit * | |
git pull --rebase origin ${BRANCH} | |
git lg -5 | |
# * check all looks nice and clean * | |
git push ${GITUSER} ${TOPIC} | |
# this next step requires that you install hub first: https://github.com/defunkt/hub#readme | |
# alternatively, you can do a pull request in your browser from https://github.com/${GITUSER}/jbosstools-<component> | |
hub pull-request "${TOPIC} (apply in ${BRANCH} from ${TOPIC})" -b jbosstools:${BRANCH} -h ${GITUSER}:${TOPIC} | |
# -------------------- | |
# purge old topic branch | |
git checkout master | |
git branch -D ${TOPIC} | |
TOPIC= |
mmalina - the orgin convention turns out to be problematic.
with hub (nick, doesn't mention he got this setup here) and actually when trying to keep track of multiple remotes, its much nicer if origin is the Actual origin (i.e. the "master repo").
about #29: no need to write "apply in branch from topic" in the message since that is something github already tells you.
Much more relevant to mention the jira and what has happened/changed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By convention, origin is used for your own fork whereas upstream is usually used for the main github repo.
Also, on line 18 you run git pull before checking out the branch. I would switch those two lines (18 and 19) otherwise it's non-deterministic - git pull "Incorporates changes from a remote repository into the current branch" and on line 18 you don't know yet what branch you're at.
Otherwise it looks good.