git 为什么我无法在 GitHub 中打开我的文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28384464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:54:07  来源:igfitidea点击:

Why can I not open my folder in GitHub?

gitgithub

提问by Anushka

The "src" folder in one of my repositoryis grayed out (and is not clickable):

我的存储库之一中的“src”文件夹呈灰色(并且不可点击):

screenshot

截屏

I took the following steps before pushing to the GitHub:

在推送到 GitHub 之前,我采取了以下步骤:

  1. I created a new repository on GitHub.
  2. I initialize dthe git on my project.
  3. git add .
  4. git commit -m "comment"
  5. git remote add origin url
  6. git push -u origin master
  7. username
  8. password
  1. 我在 GitHub 上创建了一个新存储库。
  2. 我在我的项目中初始化了 git。
  3. git add .
  4. git commit -m "comment"
  5. git remote add origin url
  6. git push -u origin master
  7. 用户名
  8. 密码

The "src" folder is showing up on GitHub but cannot be opened. What can I do?

“src”文件夹显示在 GitHub 上,但无法打开。我能做什么?

回答by Ivan Aracki

I solved the problem by deleting .git folderinside subfolders (Hidden files and folders). You should have only one .gitin the root folder.

我通过删除子文件夹(隐藏文件和文件夹)中的.git 文件夹解决了这个问题。您应该在根文件夹中只有一个.git

Git recognized that folder as modified but untracked content.
There are other solutions for this problem, look this thread: Git - how to track untracked content?

Git 将该文件夹识别为modified but untracked content.
这个问题还有其他解决方案,看看这个线程:Git - 如何跟踪未跟踪的内容?

回答by CodeWizard

The icon mean that you have marked this folder as submodule. open your .gitmodules and you will see there the folder named as src bin.

图标表示您已将此文件夹标记为submodule。打开你的 .gitmodules,你会看到名为 src bin 的文件夹。

Remove them from your submoduleand it will become a regular folder

从您的submodule文件夹中删除它们,它将成为一个常规文件夹

What is this grey git icon?

这个灰色的 git 图标是什么?

回答by Fabio Poloni

If you clone the project you will find, that these folders are in fact empty:

如果您克隆该项目,您会发现这些文件夹实际上是空的:

?$ ls -la bin
total 0
drwxr-xr-x+ 2 fabiopoloni  staff   68  8 Okt 12:18 .
drwxr-xr-x+ 8 fabiopoloni  staff  272  8 Okt 12:18 ..

?$ ls -la src
total 0
drwxr-xr-x+ 2 fabiopoloni  staff   68  8 Okt 12:18 .
drwxr-xr-x+ 8 fabiopoloni  staff  272  8 Okt 12:18 ..

There is also no .gitmodulesso it'll show you an error when viewing the status / syncing it:

也没有,.gitmodules所以它会在查看状态/同步时向您显示错误:

?$ git submodule status
No submodule mapping found in .gitmodules for path 'bin'

?$ git submodule sync
No submodule mapping found in .gitmodules for path 'bin'
No submodule mapping found in .gitmodules for path 'src'

Since they're empty, the easiest way is to delete them and commit:

由于它们是空的,最简单的方法是删除它们并提交:

?$ rm -rf bin
?$ rm -rf src
?$ git commit -a -m 'Removed empty submodules folders'
$ git push

回答by Aakanksha Duggal

I encountered the same issue.

我遇到了同样的问题。

The command I gave was :

我给的命令是:

git add <foldername>

The problem here is we forgot to mention that we need this as a folder :

这里的问题是我们忘记提到我们需要它作为一个文件夹:

git add <foldername>/

With the backslash , we can now see that all the files of this folder are getting displayed and this works for me!

使用反斜杠,我们现在可以看到该文件夹​​的所有文件都显示出来了,这对我有用!

回答by Terchil? Marian

I tried everything from above and nothing seemed to work in my case so I just renamed the trouble folder in something else then Github recognized it for some reason when I pushed the changes.

我尝试了上面的所有内容,但在我的情况下似乎没有任何效果,所以我只是将故障文件夹重命名为其他内容,然后 Github 在我推送更改时出于某种原因识别了它。

回答by Tanishq Vyas

There are two possible reasons to this

这有两个可能的原因

  1. You have a git folder within a git folder i.e. your src folder is a git folder itself. To fix that simply delete the .git folder within the src and
  1. 您在 git 文件夹中有一个 git 文件夹,即您的 src 文件夹本身就是一个 git 文件夹。要解决这个问题,只需删除 src 中的 .git 文件夹,然后
git add <foldername>
git commit -m "commit msg"
git push origin master

Incase if it still doesn't get fixed then, there maybe the problem because of cache. To fix that simple type

如果它仍然没有得到修复,那么可能是因为缓存的问题。修复那个简单的类型

git rm --cached <foldername>

and repeat the above steps again. Your problem should get fixed.

并再次重复上述步骤。你的问题应该得到解决。