开发者

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

开发者 https://www.devze.com 2023-03-16 06:53 出处:网络
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'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 'applica开发者_高级运维tion/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.


From your output, it looks like calendarclass.php doesn't exist. If you want to create the file, then add it to git, do:

touch calendarclass.php
git add calendarclass.php


I bet your calendarclass.php is not noticed by git because of a rule in a .gitignore file. Remove that rule and you will be able to add the file.


Remove whitespaces from the tail of your filename.


It looks like calendarclass.php does not exist to add it, and it seemed you have not modified your code after last commit that's why there are no unstaged nor staged files, may be you merged from another branch into master locally, that's why it says it is ahead of 'origin/master' by 2 commits.

0

精彩评论

暂无评论...
验证码 换一张
取 消