gpt4 book ai didi

git 推送子模块

转载 作者:太空狗 更新时间:2023-10-29 13:54:06 25 4
gpt4 key购买 nike

我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com