1

Kiddie question here -- I've read all kinds of posts about git add and can't find this situation.

I've been working on some files on my own computer without even thinking about Git or version control and I just now created a repository on Github to start tracking these better/learn git for my own edification. What I want to do is initialize a local repository, add the existing files on my computer, and then push them to the repository I have on Github. I am using a Mac with version 10.6.8.

With the files I have there is a parent directory, and then a couple of child directories and they each have a few files in them -- enough to make it tedious to just manually create and copy them all on Github.

So based on all kinds of documentation that I'm reading, I think I should be doing the following:

1) cd Users/myname/Documents/etc.etc.etc./most-high-level-directory-of-my-project-on-my-local-machine

2) git init
-- terminal says:
Reinitialized existing Git repository in /Users/.../.../most-high-level-directory-of-my-project-on-my-local-machine/.git/

3) git status (just to check, I'm not expecting files in the index yet)
-- terminal says:
# On branch master
nothing to commit, working directory clean

4) git add * (this is where I'm expecting git to add all of the child folders/files of the current directory to the index, so I can them commit them and push them to Github)
-- terminal doesn't say anything. no error messages. no success messages.

5) git status
-- terminal says:
# On branch master
nothing to commit, working directory clean

I've tried different things at #4 and tried it from a couple of different directories after it didn't work where I initialized my repo:
git add .
git add (specific path to the parent folder)
git add (a specific file just to see if that one file would get added to the index)

Everything I read says it should just work if a repo is initialized, but no matter what I do this command does absolutely nothing.

I feel like I have to be missing an extremely basic concept about how this whole process works, but none of the tutorials or questions I have read address the issue of git add just not doing anything after I've initialized a repo. Any thoughts as to what might be causing this? Gracias!

nulltoken
  • 64,429
  • 20
  • 138
  • 130
dlb8685
  • 351
  • 3
  • 10

2 Answers2

2

From this response to git init, looks like this is already a previously configured Git repository:

Reinitialized existing Git repository in /Users/.../.../most-high-level-directory-of-my-project-on-my-local-machine/.git/

You might want to check if you already have an existing .gitignore file then, as this will filter out files and cause them not to be added when you use git add with wildcards.

To check if this is the case, you can also try adding a single file by hand. If the file is being excluded due to .gitignore settings, git will tell you and prompt you to add with -f if you really want.

michel-slm
  • 9,438
  • 3
  • 32
  • 31
  • Thanks. I knew that I had initialized it a short time before, but I didn't realize that initializing it again was superfluous (I had started a new terminal session, etc.) What I'm piecing together is that I had already committed the files (when I was trying this earlier today) and didn't realize that had persisted. So specifically using .gitignore wasn't necessary, but thinking about reinitializing was useful. I was able to eventually push this to my remote. – dlb8685 Feb 22 '14 at 20:31
  • Aha! Good to know. FYI you can quickly check the status of a given file using ``git log FILENAME`` (if you omit the filename it gives you the revision log for the entire repository). Or use a graphical browser, SourceTree (sourcetreeapp.com) is really good on Macs – michel-slm Feb 22 '14 at 20:41
1

When you do a git status you should see a list of untracked files. Did you already have a git repository in that directory? Type git log to see previous commits. If this is indeed an existing repo, you can add your Github repo as a remote by typing

git remote add github http://url-to-github-repo

Where github above is the name you want to give the remote.

Dave Zych
  • 21,581
  • 7
  • 51
  • 66
  • As mentioned in the other post, I had already committed files in a previous session and didn't realize that had persisted (I got a bunch of errors trying to push the commit and was confused enough to think I hadn't committed yet). I did still need to set up a remote correctly (had to set up an SSH as well), so thinking about doing that was helpful. Was able to get everything pushed a moment ago. Thanks! – dlb8685 Feb 22 '14 at 20:35