0

I've been working on a project that's fairly far a long now and I decided it's time to use some sort of version control etc. I decided to go with github. Before I get in too deep let me state explicitly that I am new to github.

My project resides in a directory that contains myriad subdirectories and files of all different kinds. I'd like to take my project directory as is (structure and all) and put it in my github repo.

I followed the tutorials on github's webpage, created the repo, and manually added some files. Obviously I don't want to manually add every file (there are several hundred). I'd like to know how I can add the root directory or for that matter any parent directory and all files/folders in said said directory. In other words I'm looking for a recursive add.

I read on this SO page (How to create folder in github repository?) that you can just use

git add directory/

That works fine for me when I'm dealing with the lowest level directory, but when I try the same command on a directory with subdirectories my terminal just sits there and I have to ctrl-c. I can't tell if it's just taking a long time (as I mentioned there are lots of files) or if this is just the wrong way to add a directory with subdirectories.

Apologies in advance if this is a super ignorant question -- I have looked at a lot of blogs/posts/etc and I cannot find a solution that seems to work.

Community
  • 1
  • 1
Doov
  • 863
  • 2
  • 12
  • 25

2 Answers2

1

Use the Current Working Directory

Assuming you're on Linux or OS X, from the command line you would do the following:

git add .

from the root of your repository tree. That will add all non-ignored files, including non-empty directories, into the repository.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • Thanks! I actually saw that elsewhere and tried that and ctrl-c'ed it because it was seemingly stalled. I let it run for a while (several minutes) and it completed. Checked with status -s and it appears to be fine. I guess it just takes a while to compute the hashes for everything when there are a ton of files? – Doov Jul 03 '13 at 20:17
  • @Doov It certainly can, because git-add has to modify the index for every file in the tree. If you have an extremely large tree, and especially if you have a lot of large binary blobs, it may take more time than you expect. – Todd A. Jacobs Jul 03 '13 at 20:21
  • Ah, makes sense. I do indeed have extremely large binary blobs. Thanks for the answer/explanation! – Doov Jul 03 '13 at 20:33
0

From the root directory (the one with all the subdirectories), use git add -A.

If you have a ton of subdirectories and files, it may take a long while, so just let it sit there until it's done.

Chetan
  • 46,743
  • 31
  • 106
  • 145