关于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子模块支持的很不错,操作很方便。如下图:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值