关于git sub module提交失败的问题。

使用子模块的原因:因为很多工程,会有很多相同的代码,每个工程都复制一遍,会很不合适。像Svn可以指定某个目录对应的checkout很方便,对于git也有这样的sub module功能。使用node开发,不需要将它放到npm上面。

客户端我用的是Tortoise git,新建一个git库后,再把另个一个git做为子模块,结果发现修改子模块总是不能提交。

报错如下:

git.exe push --progress "origin" develop:develop
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 607 bytes | 607.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: error: refusing to update checked out branch: refs/heads/develop
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To D:/work/lrabc/xx-factoring-cloud-abc
! [remote rejected] develop -> develop (branch is currently checked out)
error: failed to push some refs to 'D:/work/lrabc/xx-factoring-cloud-abc'

后来,反复比较发现,在用Torotise git添加子模块的时候,用的是本地工程路径,不是远程路径,所以就会使用报错。

如下右键菜单:

注:git可以有本地库的,用本地库的时候,增加子模块,就可以用本地库了。

另外:现在vscode对git子模块支持的很不错,操作很方便。如下图:

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页