Great!
One of the developers approached me after that conversation and said, "umm, so how exactly do I do pull requests?" On Github, here's how I do it:
# CD into the project
$ cd Documents/project/project_repo/
# Check what branch I'm on (almost always should be master when I'm starting a new feature)
$ git branch
* master
# Pull to make sure I have the latest
$ git pull
Already up-to-date.
# Make a new branch off master. This will be my feature branch and can be named whatever I want. I prefix all my feature branches with cmp_ so people know who did most of the coding on it.
$ git branch cmp_NEWFEATURE
# Switch to my new branch
$ git checkout cmp_NEWFEATURE
Switched to branch 'cmp_NEWFEATURE'
#####
# DEVELOP.
# Commit my changes because they're awesome
# Develop more stuff. Make changes, etc.
# Commit my changes, because they're awesome.
# Pull from master and merge to make sure my stuff still works.
# NOW I'm ready to make a pull request.
#####
# push my branch to origin
$ git push origin cmp_NEWFEATURE
# Create the pull request
# I do this on github. See https://help.github.com/articles/using-pull-requests
# Set the base branch to master and the head branch to cmp_NEWFEATURE
# Twiddle my thumbs waiting for the pull request to be approved.
# When it's approved, huzzah!
# If the reviewer said, "go ahead and merge", then the merge is on me to do.
# Check out the master branch. This is what I'll be merging into
$ git checkout master
# Merge from my pull request branch into master. I use --squash so the whole merge is one commit, no matter how many commits it took on the branch to get there.
$ git merge --squash cmp_NEWFEATURE
# If the merge isn't clean, go ahead and fix and commit.
# Push my newly-merged master up to origin. The pull request is done!
$ git push
# Go into github and close the pull request. I do this in a browser.
# Delete the feature branch from origin. Tidiness is awesome.
$ git push origin :
# Delete my local copy of the feature branch.
$ git branch -D
More information can be found here: https://help.github.com/articles/using-pull-requests.
Happy pulling!
No comments:
Post a Comment