#Reviewing Pull Request Workflow and Heroku Deployment
##Git
###Pull Request Workflow for a New Feature
Whenever you are working on a new story or a batch of small, related stories, you should open a new branch for that purpose. You'll want to:
git status
: Check to make sure you haven't modified anything locally before beginning. If there's anything here, decide what to do with it before checking out the master branch for branching off from.git checkout master
git pull origin master
: Pull down any changes made to master since your last pull.git checkout -b mlg-sweet-feature
: Check out a new branch with the-b
flag. A nice naming convention is the initial(s) of the person(s) working on the branch and then a brief description of the feature or story in question.- Write a test. Make it fail. Write code to make it pass. Satisfy the requirements of your user story.
git add
,git commit -m "Meaningful message"
.git push origin mlg-sweet-feature
: Push your changes up to a remote branch of the same name on Github.- If you use the
hub
gem, runhub browse
to open up the repository, or just navigate to it on Github in your browser. - You'll see a green button for opening a new pull request. Click it, add any notes or modify the title of said pull request, and then open it!
- Wait for feedback, refactor, etc. You can and should push any changes to the same branch to take advantage of the revision process on Github.
- Merge! (Use the big green button on Github, then delete the branch)
###Don't Panic! Common Git Scenarios You May Run Into
####I started making changes on master
. Crap.
It's okay! The easiest thing to do is just git checkout -b branch-name
. You'll bring any changes you made to master
with you, assuming you haven't added or committed them yet. Run git status
first to check them out and make sure there's nothing you don't mean to bring along with you.
####I messed up a file and I want to get it back to how it was when I started working on this feature.
Cool. Run git checkout filename.ext
to check out that file in its state at your last commit.
####Github says my branch cannot be merged automatically.
Okay! Somebody has made changes to master
since you last pulled it into your branch. Run git pull origin master
from your branch and watch the logs in your terminal carefully. If you have any merge conflicts, go to those files and resolve them. One good way to find the conflicts is to do a global search for <<<<<
. Make sure you delete these lines from your codebase before adding and committing.
####Should I branch off of a branch?
You can, but it can get complicated quickly, and some people feel that this is a bad practice. For now, I'd recommend making a new branch off from master
and just write the minimum amount of code necessary to make your feature work with the features in progress in another branch. You'll have to resolve some merge conflicts later on, but it should be easy enough to do if you work together with the pair or person that wrote that branch.
###More Help Using Pull Requests | Github Help
This site has some good explanations of commonly used git commands.
Try out the Code School courses on Git, which are cheesy but good for drilling syntax.
Github has video content for the visual among you. This is a good introduction.
##Heroku Deployment (Early & often!)
This should be everything you need to deploy for the first time.
Basic summary:
- Install the Heroku Toolbelt
- Run
heroku create
- Run
git push heroku master
After you've set up your initial deploy, make sure the others in your group have admin access to your Heroku app. You can do this from your dashboard on Heroku.com.
From now on, daily or even whenever you have a few feature branches merged into master
, you should git checkout master
, git pull origin master
, and then git push heroku master
from your app directory. You should only be pushing your master branch up to production (Heroku) for the sake of group project workflow.
Then heroku open
to check out your handiwork!