27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.1.2 Version control<br />

Application setup<br />

It is wise during development to use version control software to provide checkpoints<br />

in your code. When the code is working, you can make a commit, and if anything goes<br />

wrong later in development, you can revert to the commit. Additionally, you can create<br />

branches for experimental features and work on those independently of the main<br />

code base without damaging working code.<br />

This book doesn’t go into detail on how to use a version control system, but it does<br />

recommend using Git. Git is a distributed version control system that is easy to use and<br />

extremely powerful. If you wish to learn about Git, we recommend reading Pro Git, a<br />

free online book by Scott Chacon. 2<br />

Git is used by most developers in the Rails community and by tools such as Bundler,<br />

discussed shortly. Learning Git along with Rails is advantageous when you come<br />

across a gem or plugin that you have to install using Git. Because most of the Rails<br />

community uses Git, you can find a lot of information about how to use it with Rails<br />

(even in this book!) should you ever get stuck.<br />

If you do not have Git already installed, GitHub’s help site offers installation guides<br />

for Mac, 3 Linux, 4 and Windows. 5 The precompiled installer should work well for Macs,<br />

and the package distributed versions (APT, eMerge, and so on) work well for Linux<br />

machines. For Windows, the msysGit application does just fine.<br />

For an online place to put your Git repository, we recommend GitHub, 6 which offers<br />

free accounts. If you set up an account now, you can upload your code to GitHub as you<br />

progress, ensuring that you don’t lose it if anything were to happen to your computer.<br />

To get started with GitHub, you first need to generate a secure shell (SSH) key, which<br />

is used to authenticate you with GitHub when you do a git push to GitHub’s servers. 7<br />

Once you generate the key, copy the public key’s content (usually found at ~/.ssh/<br />

id_rsa.pub) into the SSH Public Key field on the Signup page or, if you’ve already signed<br />

up, click the Account Settings link (see figure 3.1) in the menu at the top, select SSH<br />

Public Keys, and then click Add Another Public Key to enter it there (see figure 3.2).<br />

Figure 3.1 Click Account Settings.<br />

2 http://progit.org/book/.<br />

3 http://help.github.com/mac-set-up-git/. Note this lists four separate ways, not four separate steps, to install Git.<br />

4 http://help.github.com/linux-set-up-git/.<br />

5 http://help.github.com/win-set-up-git/.<br />

6 http://github.com.<br />

7 A guide for this process can be found at http://help.github.com/linux-key-setup/.<br />

47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!