[英]How can I add a new file to my Git repository?
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我正在创建一些新文件并尝试添加它们,但是当我使用git add applications/libraries/calendarclass.php
时,它不会识别出我在那里有文件
I just created that file in textmate and am staring at it.我刚刚在 textmate 中创建了该文件并正在盯着它看。 How do I add it to git?如何将其添加到 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
当我使用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.
然后您应该看到准备添加的文件 - 然后键入git add (filename)
或git add.
if you want to add all of them.如果你想添加所有这些。
If touch
ing 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.如果touch
文件不起作用,您可能需要查看您的.gitignore
以确保其中没有发生有趣的事情,例如 exclude all 或任何类似的事情。
From your output, it looks like calendarclass.php
doesn't exist.从您的 output 看来, calendarclass.php
不存在。 If you want to create the file, then add it to git, do:如果要创建文件,然后将其添加到 git,请执行以下操作:
touch calendarclass.php
git add calendarclass.php
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.它看起来像 calendarclass.php 不存在添加它,并且似乎您在上次提交后没有修改您的代码,这就是为什么没有未暂存或暂存文件的原因,可能是您从另一个分支合并到本地 master,这就是它说的原因它领先于 'origin/master' 2 个提交。
I bet your calendarclass.php is not noticed by git because of a rule in a.gitignore file.我敢打赌,由于 a.gitignore 文件中的一条规则,git 不会注意到您的 calendarclass.php。 Remove that rule and you will be able to add the file.删除该规则,您将能够添加该文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.