[英]Git won't add any files - just an empty directory
我一直在Xcode中開發一個iPhone項目,並決定我想把它放在github上。 我在github上創建了一個repo,克隆了它,並將我的所有文件都移到了目錄中。 然后我試圖
git add Directory .
我承諾並推動,發現現在repo中唯一的東西就是這個目錄。 它什么都沒有 - 我甚至無法點擊它在github文件查看器中為repo打開它。 它是文件夾和文件夾名稱的圖片。 我試過了
git add Directory .
git add Directory -A
git commit -a
什么都不會將這些文件添加到目錄中。 我究竟做錯了什么?
可能存在另一個存儲庫。
我的vimfiles中的插件目錄發生在我身上。 再現這樣 :
vim-easymotion
)到你的存儲庫的某個地方(在我的例子中是vimfiles\\bundle
) git add .
,然后git status
將顯示所有已實現的是文件夾名稱(在本例中為bundle\\vim-easymotion
)已添加為new file
git commit
,然后git push origin master
(將更改推送到GitHub) 我只是意識到發生了什么,從我在Git Bash的vimfiles\\bundle\\vim-easymotion
目錄中,我發出了git config -l ,並注意到對vim-easymotion
存儲庫的所有者Lokaltog
的引用。 所以我發布了git remote -v
,果然,在該目錄中,Git別名origin https://github.com/Lokaltog/vim-easymotion.git
,這不是我的存儲庫的遠程地址,而是插件的遠程地址。 對我的無知感到震驚,我使用FreeCommander導航到插件目錄,顯示隱藏文件,當然插件創建者的.git
文件就在那里。
固化 ,假設你已經克隆別人的倉庫到你的,我做的:
find . | grep /.git | xargs rm -rf
find . | grep /.git | xargs rm -rf
find . | grep /.git | xargs rm -rf
刪除所有不需要的.git
文件 git remote -v
檢查你是否回到了你自己的遙控器的別名 git status
現在將報告文件已被刪除(在我的情況下是vim-easymotion
) git add -A
進行刪除, git commit
和git push origin master
從GitHub遠程刪除那個daft文件名 git add .
而在目錄中應該添加所有內容,除非你的.gitignore文件忽略它...
試試git add .
或者使用git gui並通過單擊圖標來選擇其中的文件然后提交它們。
git不跟蹤目錄 - 它跟蹤文件和目錄來獲取。 如果顯式添加文件,則該目錄將作為文件路徑的一部分包含在內。 要添加目錄內容git add Directory/*
可以完成這項工作。
聽到git add . ; git commit
,我很驚訝git add . ; git commit
git add . ; git commit
git add . ; git commit
不適合你。 您確定從repo中最頂層的目錄運行這些命令嗎? 以下是您通常期望發生的事情的摘要:
cd ~/Directory # or whatever the path is in your case
git status # shows lots of "Untracked files" because this is a new repo
git add . # adds everything to your index
git status # now shows lots of "Changes to be committed"
git commit # fires up the editor and finishes the commit
git show # shows the commit you just made
在什么時候這會讓你失望?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.