我正在尝试将工作区中现有的Java项目添加到我的git代码库中。
我在Linux上使用git版本1.8.3.2。
我使用以下命令:
git init/committed/remote origin/pushed
然而,src目录只显示为空文件夹且为灰色。
我如何将一个包含子文件夹的文件夹添加到我的Github仓库中?
这就是它的样子。请注意,"src"是灰色的且无法点击。
src
和bin
是git子模块
。它们不可浏览,因为它们只是指向其他git仓库的指针,而不是真正的“文件夹”。
要使用一个命令将目录及其子目录中的所有内容添加到git中,可以使用git add .
,它会递归地添加。
Pro Git书的第6节解释了什么是子模块。
假设您不想要子模块,可以按照以下方式修复您的存储库:
cd <project> # Go to the projects root
rm -rf .git # Remove all git information (keeping your code).
cd src # and repeat for src and bin
rm -rf .git
cd ../bin
rm -rf .git
cd .. # now, back in the projects root
git init # Make a git repository
git add . # Add everything to it
git commit -m 'Initial commit'
git remote add github <github-url>
git push -f github # Force push to github, to overwrite everything we had before.
src
和bin
中的git仓库!!我非常确定这就是你想要做的。
添加*.*
文件和文件夹的方法如下:
git init
git add .
git commit -m "This is my commit"
git push origin master
顺便说一句:您可以在以下教程中找到更简化的详细信息: 将现有的未版本控制代码项目导入空存储库
git init
之后,你是否将所有内容添加到仓库中了?(使用git add .
命令?) - simontsrc
和bin
的这里,它们被称为“子项目提交”。阅读这篇文章、这篇文章和Pro Git书籍以了解什么是子模块。这些目录不可浏览,因为它们是其他Git存储库。 - simont