git 推送子模块

标签 git

我使用 git clone 将存储库 A 克隆到存储库 B。/somedirectory/b.git 。后来,我决定在 B git submodule add/path/to/c.git c_in_b 中子模块存储库 C。那么我该如何将这个子模块的添加推回 A?

尝试使用git push但出现以下错误

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

最佳答案

这是因为您正在尝试推送到非裸仓库。首先创建裸存储库。只需将 --bare 添加到克隆命令即可。

发生这种情况的原因是为了防止丢失工作。拥有工作目录意味着如果要在外部更新分支,您可能会丢失工作。

关于git 推送子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6414675/

相关文章:

python - 如何发现 'pip install git+ssh://...' 在哪里搜索 ssh key ?

linux - Git删除所有未修改的文件

linux - 从文件树中删除 git-annex 存储库

c++ - 构建 Qt 应用程序时如何运行 git 命令

java - GIT 分支可以有数据子集吗?

git - 如何防止 git vimdiff 以只读方式打开文件?

git - 查找 fork 上哪些提交是新的

git - 列出 GIT 历史中给定行号的所有版本

windows - Vim 插件不适用于病原体

git - SVN 提交与 Git 提交