1. Technology

Using the Git Version Control Tool with Ruby

While Git is not written in Ruby, nor is it a tool used exclusively by Rubyists, Git is the source code version control software used by many Rubyists. Git and Ruby are a natural fit, allowing you to manage small and large personal projects, as well as to collaborate with others quite easily. Git is also the heart of the popular source code sharing website, GitHub.

Using Git with Ruby
Git is a powerful and, most importantly, convenient source code manager that's compatible with both Ruby and the agile development methodology.

Installing Git on Windows
Installing command line tools such a Git on Windows is often difficult. Not only do you have to find a Windows port or attempt to compile the tool yourself from C source code, you also have to deal with the Windows command line. The Windows command line is, to say the least, a little lacking. Windows users are in luck here though, the MSysGit project solves both these problems.

Installing Git on Linux
There are multiple ways of installing Git on Linux. Depending on which Linux distribution you're using and whether it provides binary packages for Git, you can either install a binary package or install from source.

Creating a New Repository
A Git repository is not like a repository in most other version control systems. Normally, you'll have something like a CVS or Subversion server where the repository lives. From that, you'll check out a working copy, make your changes to that and commit them. Git is different though, there is no centralized server.

Adding Files to a Repository
How to add files to a Git repository.

Committing Changes
The Git repository tracks the status of all files in your project. However, it doesn't know exactly what you've done until you commit your changes. Committing changes tells Git to look at all the files, find the changes you made as well as any new files and integrate them all into the Git repository. Until you make a commit, any changes made are in limbo and not yet part of the repository.

Use 'status' When You're Lost
It's easy to get lost when using Git. You essentially have two sets of files, your working set and the set in the repository. Keeping track of which files have changed is important.

Getting a Diff
Getting a list of changes is useful, but what about getting a diff of what exactly was changed? A diff is a listing of all parts of a file that differ. So, for example, it'll tell you that you removed three lines and added 4 new lines. It's a way of both seeing what was changed and sending those changes to other developers without having to send them the entire file.

Retrieving a Tagged Release
Once you have releases tagged in the repository, it will be useful to retrieve tagged releases. For example, I want to see if a bug was present in version 0.3, so I'll want to retrieve version 0.3 and run it. Git, of course, makes this easy.

Tagging Releases
A Git repository represents the entire history of a project. From the initial import to the latest unstable version (the master branch), every version of every file is represented in the repository. Besides branches, Git has a handy way of referring to a specific version of all the files in the repository: tags.

Git Homepage
Here you'll find general information about Git, Git downloads, documentation and the Git wiki.

MSysGit is a Windows port of Git packaged with a Bash command line. This is the easiest way to install Git on Windows.

Can I add empty directories to Git repositories?
Can I add empty directories to Git repositories?

How to Install Git
How to install Git on Windows, Linux or Mac OS X.

You can opt-out at any time. Please refer to our privacy policy for contact information.

©2014 About.com. All rights reserved.