How do I add a new file to my Git repository?

advertisements

I'm creating some new files and am trying to add them but when I use git add applications/libraries/calendarclass.php, it won't recognize that I have a file there

I just created that file in textmate and am staring at it. How do I add it to git?

releventz$ git add application/libraries/calendarclass.php
fatal: pathspec 'application/libraries/calendarclass.php' did not match any files
releventz$ ls
application css     index.php   license.txt
authnet     images      js      system
releventz$ cd application
application$ ls
cache       controllers errors      hooks       language    logs            third_party
config      core        helpers     index.html  libraries   models          views
application$ cd libraries
libraries$ ls
MY_Unit_test.php    index.html      loginclass.php
libraries$ git branch
* master
libraries$ git add calendarclass.php
fatal: pathspec 'application/libraries/calendarclass.php' did not match any files

When I use git status

libraries$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)


After adding your new file, type:

git status

You should then see the file ready to be added - then either type git add (filename) or git add . if you want to add all of them.

If touching the file doesn't do the trick, you may need to take a look at your .gitignore to make sure there's no funny business going on in there, like an exclude all or anything similar.