来初始化我使用 Hugo Newsite Hugo-G 创建的根文件夹时,我发现根文件夹中的所有子文件夹都没有添加到 git 中。
以下是文件权限详细信息:
╰─ ll -al
total 16
drwxr-xr-x 12 robot staff 384B Jul 20 22:50 .
drwxr-xr-x 51 robot staff 1.6K Jul 18 16:22 ..
drwxr-xr-x 9 robot staff 288B Jul 20 22:50 .git
drwxr-xr-x 3 robot staff 96B Jul 10 17:56 archetypes
-rw-r--r-- 1 robot staff 7.8K Jul 20 20:23 config.toml
drwxr-xr-x 4 robot staff 128B Jul 20 21:11 content
drwxr-xr-x 2 robot staff 64B Jul 10 17:56 data
drwxr-xr-x 2 robot staff 64B Jul 10 17:56 layouts
drwxr-xr-x 13 robot staff 416B Jul 20 22:01 public
drwxr-xr-x 3 robot staff 96B Jul 19 11:13 resources
drwxr-xr-x 2 robot staff 64B Jul 10 17:56 static
drwxr-xr-x 7 robot staff 224B Jul 20 22:33 themes
以下是我完成操作后的结果:git init
╰─ git init
Initialized empty Git repository in /Users/robot/code/interests/hugo-g/.git/
╰─ ls
archetypes config.toml content data layouts public resources static themes
╰─ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
archetypes/
config.toml
public/
themes/
nothing added to commit but untracked files present (use "git add" to track)
#I tried with commands provided by @Sepideha and @melpomene, but it still not works, and the result is like this.
git add .
git status
new file: archetypes/default.md
new file: config.toml
new file: public/404.html
new file: public/archives/index.html
new file: public/archives/index.xml
new file: public/categories/index.html
new file: public/categories/index.xml
new file: public/css/style-twzjdbqhmnnacqs0pwwdzcdbt8yhv8giawvjqjmyfoqnvazl0dalmnhdkvp7.min.css
new file: public/images/cover-v1.2.0.jpg
new file: public/images/cover.jpg
new file: public/index.html
new file: public/index.xml
new file: public/js/script-pcw6v3xilnxydl1vddzazdverrnn9ctynvnxgwho987mfyqkuylcb1nlt.min.js
new file: public/page/1/index.html
new file: public/sitemap.xml
new file: public/tags/index.html
new file: public/tags/index.xml
new file: themes
git add *
git status
new file: archetypes/default.md
new file: config.toml
new file: public/404.html
new file: public/archives/index.html
new file: public/archives/index.xml
new file: public/categories/index.html
new file: public/categories/index.xml
new file: public/css/style-twzjdbqhmnnacqs0pwwdzcdbt8yhv8giawvjqjmyfoqnvazl0dalmnhdkvp7.min.css
new file: public/images/cover-v1.2.0.jpg
new file: public/images/cover.jpg
new file: public/index.html
new file: public/index.xml
new file: public/js/script-pcw6v3xilnxydl1vddzazdverrnn9ctynvnxgwho987mfyqkuylcb1nlt.min.js
new file: public/page/1/index.html
new file: public/sitemap.xml
new file: public/tags/index.html
new file: public/tags/index.xml
new file: themes
the subfolder like data, content,layouts, resources... still miss.
tree -L 2
╰─ tree -L 2
.
├── archetypes
│ └── default.md
├── config.toml
├── content
│ ├── page
│ └── post
├── data
├── layouts
├── public
│ ├── 404.html
│ ├── archives
│ ├── categories
│ ├── css
│ ├── images
│ ├── index.html
│ ├── index.xml
│ ├── js
│ ├── page
│ ├── sitemap.xml
│ └── tags
├── resources
│ └── _gen
├── static
└── themes
├── AllinOne
├── BeyondNothing
├── Binario
操作系统:达尔文机器人本地 18.6.0 达尔文内核版本 18.6.0: PDT 2019 年 4 月 25 日星期四 23:16:27; 根:xnu-4903.261.4~2/RELEASE_X86_64 x86_64git 版本:版本 2.20.0雨果版本:雨果静态站点生成器 v0.55.6/扩展达尔文/amd64 构建日期:未知Go版本:Go版本Go1.12.5达尔文/AMD64
我希望根文件夹中的所有子文件夹都可以添加到 git 中。
git init
不添加任何文件。它只是创建一个(最初是空的(存储库。
如果要将目录中的所有文件和子目录添加到存储库中,则需要
git add .
git commit
(后一个命令将打开一个文本编辑器,以便您可以键入第一个提交消息。
在根目录中,您需要执行以下 3 个步骤将文件添加到 git 存储库:
git add *
git commit -m "added file to the repo"
git push
在我大学华峰的帮助下,我终于想通了原因。因此,git 不会跟踪没有文件的文件夹。我还找到了以下答案:git 会忽略空文件夹吗?那里说,Git 是一个内容跟踪器。空目录不是内容。