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

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. You can make repositories on any computer and everything a VCS server would do is tracked in the .git directory.

Once you get Git installed, creating a repository is a single command. Go to the directory where the repositories files are on the command line. For instance, change directory to the MyProject directory where the Ruby files, README and data is for MyProject. In this directory, run the command git init. It should happen almost instantaneously and you'll see a message confirming the repository was created.

You can also create a new, empty directory for your project now and run git init in it. As you add files to the project, you can add them to the git repository. In which order you start the project and create the Git repository is not important.

To confirm this happened, take a look at the .git directory. You should see various files and directories in .git. You don't have to concern yourself with these yet, but feel free to take a look around. Git is very open, it's easy to go poking around in its internals. Though there's not much of interest in here yet, at least not until we add some files and commit changes.

  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Using the Git Version Control Tool with Ruby
  6. Creating a New Repository

©2014 About.com. All rights reserved.