1

I've created a new repository and committed everything, or so I thought.

I found that there was a .gitignore in my stylesheets directory. I have removed this and did a git add . at the root of my project. In the stylesheets directory I now have a .git file.

When I try to commit I get this:

git commit
    On branch master 
    Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
    modified:   client/stylesheets (modified content)

no changes added to commit

How do I commit everything in the client/stylesheets directory?

Thanks in advance for any suggestions :)

user1532669
  • 2,288
  • 4
  • 36
  • 72
  • 5
    Your `client/stylesheets/` directory appears to be a submodule. Is that what you want? – ChrisGPT was on strike Sep 15 '14 at 23:44
  • Yeah, I want to include `client/stylesheets/` and everything contained in it to be in my repository. Any ideas? – user1532669 Sep 16 '14 at 14:31
  • Do you also need the same directory to be usable from other repositories, or is it specific to this one? – ChrisGPT was on strike Sep 16 '14 at 15:00
  • This is is part of one repository which is only to be usable by this one specific repository. – user1532669 Sep 16 '14 at 16:04
  • I'm still not understanding. What does "part of one repository which is only to be usable by this one specific repository" mean? Do you need that directory to be a submodule (essentially a separate Git project inside your main one), or not? – ChrisGPT was on strike Sep 16 '14 at 16:12
  • Sorry, I just mean it should be part of this single repository like any other directory. I don't know why it wasn't part of the initial commit, it should've been (as far as I know). – user1532669 Sep 16 '14 at 16:58

1 Answers1

1

It looks like you've got nested Git repositories.

In general this is not permitted, though there are instances where it makes sense (e.g. when using submodules). You might have gotten into this state by accidentally running git init in a subdirectory, or by cloning into a subdirectory, or something else.

If you do not want to use submodules,

  1. Look for an extraneous .git directory inside your client/ directory or possibly in client/stylesheets. This is the internal Git repository; you may want to run git log or something on it to make sure you don't need it.

    If you're sure you don't need its history you can delete it.

  2. Look for a file called .gitmodules in your main repository. If you find it, delete it.

  3. If you found a .gitmodules file in the previous step, run git rm --cached client (or client/stylesheets, depending on where you found the .git directory).

Now you should be able to commit the directory as normal:

git add client
git commit

See this answer for more details.

Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • That fixed it thank you. I had to rm the `.git` file in the stylesheets dir and then `git rm --cashed client/stylesheets` ...... adding and committing ran perfectly after that. Thank you again :) – user1532669 Sep 16 '14 at 20:20