Git不会添加任何文件 - 只是一个空目录 [英] Git won't add any files - just an empty directory

查看:404
本文介绍了Git不会添加任何文件 - 只是一个空目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究Xcode中的iPhone项目,并决定将其放在github上。我在github上创建了一个repo,克隆它,并将所有文件移动到目录中。然后我试图

I have been working on an iPhone project in Xcode, and decided I wanted to put it up on github. I created a repo on github, cloned it, and moved all my files into the directory. Then I attempted to

git add Directory .

我承诺并推送,发现目录中唯一的回购是这个目录。没有任何内容 - 我甚至无法单击它在github文件查看器中打开它以用于回购。它是一个文件夹和文件夹名称的图片。我试过了

I committed and pushed, and found that the only thing in the repo now was this directory. There is nothing in it - I can't even click it to open it in the github file viewer for the repo. It is a picture of a folder and the folder's name. I've tried

git add Directory .
git add Directory -A
git commit -a

没有东西会添加这些文件到目录。我做错了什么?

Nothing will add these files to the directory. What am I doing wrong?

推荐答案

另一个存储库可能存在。

我的 vimfiles 插件目录发生在我身上。 像这样重现

This was happening to me with plugin directories in my vimfiles. Reproduce like this:


  1. git从GitHub克隆一些东西(在我的例子中是一个插件,例如 vim-easymotion )到你的版本库(在我的情况下到 vimfiles \ bundles

  2. git add。,然后 git status 将显示所有已经实现的是文件夹名称已经添加了一个新文件

  3. bundle \vim-easymotion li> git commit ,然后 git push origin master (推送对GitHub的更改)
  4. 在浏览器中导航到GitHub以检查您在步骤1中克隆了某些内容的文件夹,并且您会看到它将克隆名称显示为空文件

  1. git clone something from GitHub (in my case, a plugin, eg vim-easymotion) somewhere into your repository (in my case into vimfiles\bundle)
  2. git add ., then git status will show that all that's been achieved is that the folder name (in this case bundle\vim-easymotion) has been added as a new file
  3. git commit, then git push origin master (pushing changes to GitHub)
  4. Navigate to GitHub in a browser to examine the folder that you had cloned something into in step 1, and you will see that it shows the clone's name as an empty file

我只知道从Git Bash中的 vimfiles \ bundle \vim-easymotion 目录发布了什么内容, git confi g -l <​​/a>,并注意到 Lokaltog 的引用, vim-easymotion 存储库的所有者。所以我发布了 git remote -v ,果然,在那个目录中,Git别名是 origin https://github.com/Lokaltog/vim -easymotion.git ,这不是我的存储库的远程地址,而是插件的地址。惊呆了我的无知,我用 FreeCommander 导航到插件目录,显示隐藏文件,当然插件创建者的 .git 文件存在。

I only realised what was going on when, from my vimfiles\bundle\vim-easymotion directory in Git Bash, I issued git config -l, and noticed a reference to Lokaltog, the owner of the vim-easymotion repository. So I issued git remote -v, and sure enough, in that directory the Git alias was origin https://github.com/Lokaltog/vim-easymotion.git, which is not my repository's remote address, but that of the plugin. Stunned at my ignorance, I navigated to the plugin directory with FreeCommander, showing hidden files and of course the plugin creator's .git files were there.

治愈,假设您有像我一样克隆别人的存储库:

The cure, assuming you have cloned someone else's repository into yours, as I did:


  1. Git Bash在违规的克隆子目录中,问题 find。 | grep /.git | xargs rm -rf 删除所有不需要的 .git 文件
  2. git remote -v 检查你是否回到你自己的远程的别名

  3. 现在暂时将整个子目录移出存储库

  4. git status 现在会报告一个文件已被删除(在我的例子中为 vim-easymotion

  5. git add -A 来执行删除操作,然后 git commit git push origin master 从GitHub的远端删除那个daft文件名

  6. 将(now clean)子目录移回您的存储库,并继续正常。

  1. Git Bash in the offending cloned subdirectory, issue find . | grep /.git | xargs rm -rf to remove all of the unwanted .git files
  2. git remote -v to check that you're back to your own remote's alias
  3. Now temporarily move the whole of that subdirectory out of your repository
  4. git status will now report that a file has been deleted (in my case vim-easymotion)
  5. git add -A to stage that deletion, then git commit, and git push origin master to remove that daft filename from your remote at GitHub
  6. Move the (now clean) subdirectory back into your repository, and continue as normal.

这篇关于Git不会添加任何文件 - 只是一个空目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆