views:

59

answers:

1

How can I add a folder recursively, with its subfolders and its files?

When I use git add folder_name, only that folder is getting added. git status now shows the files under the subfolders are shown as new files and untracked.

For example, in Rails application, inside the Rails project folder, there are many folders:

  • app
  • public
  • db
  • script
  • vendor
  • etc.

Is there a better way to add a rails project to git?

+2  A: 
cd desired_directory; git add .;

Er, it looks like this was answered by Justin L. in a comment while I as typing.

labratmatt
Wait, `cd foo; git add .` has a different result from `git add foo`?
Jefromi
@Jefromi: apparently it has. `git add foo/.` would be the same though. Although the phrase "a leading directory name (e.g. `dir` to add `dir/file1` and `dir/file2`) can be given to add all files in the directory, recursively." in the `git add` man page seems to contradict that.
VonC
@VonC: Well I've never had any trouble adding directories recursively with the obvious `git add foo` method - can't manage to reproduce the OP's problem.
Jefromi