Search code examples
xcodegitrepositorysubdirectory

Why are subfolders not being seen by the Git repository?


I have just created a local repository (using Git) for a project that will contain many subfolders (it is a pedagogical project with Lesson 1...2...3 etc..., each one with a folder within the main directory).
I connected this to the remote repository I created on GitHub.com and hoped that would have been enough to start working, pushing, committing etc... now that I have created the first Xcode project inside the main folder neither Xcode Commit function nor Terminal git commit command is seeing any change.
The symptoms I see are that the remote repository sees "Project name" folder, then "Lesson 1" folder inside it but nothing else inside "Lesson 1", where the Xcode project should be (it actually is there in the Finder).
What may have gone wrong?
What would have been the proper set of actions to create a repository in a directory that would automatically fetch every new file added to it?
Thank you so much!


Solution

  • Git will not automatically track new files you create in the directory tree which contains your local git repo.

    When you create new files, you need to inform git that you want them tracked, with the "git add" command.

    git add path-to-new-file

    If you create new files and do not add them, then when you run the "git status" command the output should contain a section labeled Untracked files, like this:

    Untracked files:
    (use "git add ..." to include in what will be committed)

    asdf.txt

    It will show the path to the file(s) relative to the top of your git repo, including the filename(s). Pass all of that to the git add command. Then commit, just as you would for changed files.