Git branching model for new users - grinnellplans/GrinnellPlans GitHub Wiki

The project uses the following git model for contributions:

Fork the project

On the main project page, click the fork button in the upper right. This will create a version of the project under your username (e.g. https://github.com/ianlunderskov/GrinnellPlans).

Pull down the fork locally

On your development machine, run git clone https://github.com/YOURUSERNAME/GrinnellPlans (replacing "YOURUSERNAME" with your Github account name).

Add the primary repository as a remote

As you work on your feature branch, you will want to get updates merged into the main repository. As such, your project will need to know where to look for these changes. Per Github's documentation (note that lines starting with # are comments for clarity, not things you should try to type in):

$ git remote add plans_remote https://github.com/grinnellplans/GrinnellPlans.git
# Set a new remote

$ git remote -v
# Verify new remote
# plans_remote  https://github.com/grinnellplans/GrinnellPlans.git (fetch)
# plans_remote  https://github.com/grinnellplans/GrinnellPlans.git (push)

Checkout a feature branch

Create a new branch to commit your new feature to. For example, if you are working on adding validations to the polls, you may do git checkout -b add_validations_to_polls

Commit your changes to the branch

After you've made your changes and added the tests (remember, tests are required), you'll want to commit them to your branch and push them to your Github repository.

$ git status
On branch add_validations_to_polls
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   app/models/poll_choice.rb
    modified:   app/models/poll_question.rb
    modified:   spec/models/poll_choice_spec.rb
    modified:   spec/models/poll_question_spec.rb


$ git add .
$ git commit -m "I updated the polls to do some validations"
# This is a junk commit message, try to give more detail

$ git push origin add_validations_to_polls

Open a pull request against grinnellplans/GrinnellPlans

Once your branch is up on Github, you'll want to create a pull request for your feature branch against the GrinnellPlans development branch.

Update against master, and start again

Pull down any changes that have been merged into the primary repository before starting your new feature branch.

$ git checkout development
$ git fetch 
$ git pull plans_remote development
$ git checkout -b your_next_feature_branch
⚠️ **GitHub.com Fallback** ⚠️