Rails Girls Next

February 19, 2014

Exercises

Tips and Tricks

Git

Before each exercise

Decide who in your group will write code first. They will be the owner of this repository (but don't worry, you'll both have a copy of it at the end!).

We're going to set ourselves up to use git properly for the rest of this guide.

On GitHub create a new repository (git project names are usually writen like your-project-name).

On your computer open terminal or command line and move to your programming directory. (This is a great time to create one if you don't have it already! It helps keep all your programming bits and pieces together.) Here are some handy hints for working in the terminal or command line.

Once you've navigated to your directory run the command git clone git@github.com:[your-github-username-here]/[your-project-name-here].git

Move into your new your-project-name directory.

Give the repository to someone else

The repo owner needs to give the other group members access to the repo.

    Each of the other group members needs to:
  1. open terminal or command line
  2. move to your programming directory
  3. clone the repo
  4. move into your new your-project-name directory

Now everyone can continue working on the exercise on their computer.

Commit during each exercise

Once you feel like you've made progress on your code, you should commit your changes locally, then push them up to the repo on GitHub. In the terminal, from within your your-project-name directory, run the follow commands:

  1. Tell git about your changes: git add -A
  2. Commit those changes: git commit -m "write your message here"
  3. Push your code up to GitHub: git push origin master

Now you can see your code at https://github.com/[your-github-username-here]/[your-project-name-here].

Push up updates

After anyone has committed changes to their local repo you can push those changes up to GitHub. In the terminal, from within your your-project-name directory, run $ git push origin master. If you go to https://github.com/[your-github-username-here]/[your-project-name-here] you should see your updated code.

Pull down updates

After anyone has pushed to your shared repo you can pull down the changes to your computer. In the terminal, from within your your-project-name directory, run $ git pull origin master - you should now have the latest code on your computer

Fork the repository

When you're all done with an exercise you can fork the repository. In usual programming groups you probably wouldn't do this. However since you likely want permanant access, even if your group members delete their repos, you should probably make a fork so you own a copy of the code yourself. Just do step 1 from these directions, and you'll have the repo listed under your name too.