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.
There are a few other things the git add command does to make your job of adding files a little easier.
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.
Source...