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

Adding Files to a Repository


Once you create a repository, it's time to add some files. There are two possibilities here, you've either created the Git repository in a new empty directory, or in a directory that already contains files. If you've created the Git repository in an empty directory, go ahead and start the project to get some files created. Even if it's just an empty Ruby file and a short README, you'll need at least something to add to the repository.

Once you have some files to add to the repository, you can add them using the git add command. So, for example, if we have the files MyProject.rb and README, we can add them to the repository like so.

 $ git add MyProject.rb
 $ git add README

There are a few other things the git add command does to make your job of adding files a little easier.

  • git add . - Add everything in the current directory recursively. This is useful if there is a large directory tree you wish to add.

  • git add file1 file2 - Add both files to the repository.

  • git add docs/\\*.txt - Adds all text files in the docs directory. Note the backslash before the asterisk, this means Git will be doing the globbing, not the shell.

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

©2014 About.com. All rights reserved.