git git不添加现有文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32000525/
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
git not adding existing folder
提问by duxfox--
I started working on a project recently, then decided to push it up to github. So I did the following:
我最近开始做一个项目,然后决定把它推到 github。所以我做了以下事情:
cd <root>
git init
git add -A
git commit -m 'message'
git remote add origin <ur>
git push -u origin master
this, however, omitted an entire folder of my project. its basically a folder 1 level down from my root folder so:
然而,这省略了我项目的整个文件夹。它基本上是一个比我的根文件夹低 1 级的文件夹,因此:
root
-folder //omitted
I'm trying to do git add -A / git add * / git add .
but every time I do git status
it says there are changes but the folder is untracked.
我正在尝试这样做,git add -A / git add * / git add .
但每次我这样做git status
时都说有更改,但文件夹未跟踪。
I even tried to specifically add the folder git add folderName
but git status
is still showing it as untracked.
我什至尝试专门添加该文件夹,git add folderName
但git status
仍将其显示为未跟踪。
I also tried to navigate into the folder itself, and do a git add *
and that added everything INSIDE of this folder, but I just cant seem to add the folder itself.
我还尝试导航到文件夹本身,然后执行git add *
并添加了该文件夹内的所有内容,但我似乎无法添加文件夹本身。
any idea what else I can do?
知道我还能做什么吗?
回答by wisbucky
A subfolder will not be added with git add .
(or similar commands) if it contains a .git
dir because it will be assumed to be a git submodule.
如果子文件夹git add .
包含.git
目录,则不会使用(或类似命令)添加子文件夹,因为它将被假定为 git 子模块。
You can rm -rf .git
in the subfolder if it's not supposed to be a submodule.
rm -rf .git
如果它不应该是子模块,则可以在子文件夹中。
回答by mipadi
Are there files in the folder? Git doesn't track folders, only files; you can't add an empty folder to a Git repo. However, you can put an empty file in that folder (.gitignore
or .blank
are common file names) and add those files to the folder.
文件夹中有文件吗?Git 不跟踪文件夹,只跟踪文件;您不能向 Git 存储库添加空文件夹。但是,您可以在该文件夹中放置一个空文件(.gitignore
或.blank
常见文件名)并将这些文件添加到该文件夹中。