git - 无法在 Git 中添加子模块

标签 git github

我无法通过 Git 将以下子模块推送到 Github。我看到以下错误消息。我做错了什么?

我按照以下步骤操作:

cd my_project
git init
git add *
git status

然后它将消息显示为:

   Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
      (commit or discard the untracked or modified content in submodules)

        modified:   server/auth (modified content)

    no changes added to commit (use "git add" and/or "git commit -a")

在我推送之后,我的子文件夹 server/auth 不会进入我的 github 存储库,请帮助我,我是新手: 我的项目结构如下: Server 作为主要模块,clientsresourceauth 作为子模块,除了“auth>”一切都在 promise 。

最佳答案

您对 Git 子模块 的定义是什么?当我查看您的 4 个步骤时,在我看来,您创建了一个新的 Git 存储库,其中包含几个子文件夹但没有 git 子模块?

如果您想为 clientsresourceauth 添加 git 子模块,您可能会这样做:

cd my_project
git init
git submodule add <global-path-to-sub-repository> **clients**
git submodule add <global-path-to-sub-repository> **resource**
git submodule add <global-path-to-sub-repository> **auth**
git submodule init
git add *
git status

关于git - 无法在 Git 中添加子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31376008/

相关文章:

git - 如何将 git 存储库从 Windows 迁移到 Linux? (CRLF - LF 问题)

git - 如何查看两个分支之间的差异?

git - 如何将 go pkg 添加到现有仓库?

azure - 将 Terraform 摘要添加为来自 Azure DevOps 的 Github PR 评论

git - 使用 Pull 时忽略开发文件

git - 如何创建个人 git 函数,每次启动 Bash 时都可用?

github - 在 github-pages 上的博客文章中添加评论

git - Windows 7 上为 "Git for Windows has stopped working"

git - 从 origin/master 分支 vs 从本地 master 分支

github - 我可以在 GitHub gui 中搜索一系列标签中的提交吗?