2011-06-30 103 views
2

我創造了一些新的文件,並正嘗試加入他們,但是當我用git add applications/libraries/calendarclass.php,也不會承認,我有一個文件如何將新文件添加到我的Git存儲庫?

我剛剛創建的TextMate的該文件,並在它正在盯着。我如何將它添加到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 

當我使用git status

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

其實,你的'ls'輸出也不會在那裏顯示文件。 git應該怎麼猜測你想在那裏添加什麼文件? –

回答

5

添加新的文件後,鍵入:

git status 

之後,應看到該文件準備加到 - 然後鍵入git add (filename)git add .如果你想添加所有這些。

如果touch該文件沒有辦法,你可能需要看看你的.gitignore,以確保沒有有趣的事情發生在那裏,比如排除所有或類似的東西。

+0

試圖在我的原帖中粘貼回覆。任何幫助,非常感謝 – David

+0

在這種情況下,我會嘗試@NickAldwin建議哪個「觸摸」文件。這應該_definitely_做到這一點。 – Nic

5

從您的輸出中,它看起來像calendarclass.php不存在。如果你想創建的文件,然後將其添加到混帳,做:

touch calendarclass.php 
git add calendarclass.php 
+0

但它確實存在,即時通訊在textmate中看... – David

+1

@David你的'ls'命令沒有顯示它。要麼你將它保存在錯誤的目錄中,或者根本沒有保存它。 – NickAldwin

+0

@David我仍然試着「觸摸」它 - 這是知道它在目錄中的一個確定的方式。 – Nic

0

我敢打賭,你的calendarclass.php不混帳注意到,因爲在.gitignore文件以規則的。刪除該規則,您將能夠添加文件。

0

從文件名尾部刪除空格。

0

它看起來像calendarclass.php不存在添加它,它看起來你沒有修改你的代碼後上次提交這就是爲什麼沒有unstaged或階段文件,可能是你從另一個分支合併到本地的主,這就是爲什麼它說2次提交就超過了「起源/主人」。

+0

或者可能文件被.gitignore忽略 –

相關問題