git子模块使用

子模块的使用

克隆项目后,默认子模块目录下无任何内容。需要在项目根目录执行如下命令完成子模块的下载:

git submodule init
git submodule update

或者

git submodule update --init --recursive

拉取子模块最新内容

git submodule foreach git pull

添加子模块

git submodule add https://子模块.git  项目子模块path

添加完毕后,项目里同时会生成 .gitmodules文件

如果添加报错

xxx目录  already exists in the index

则执行

git rm -r --cached xxx目录

更新子模块

cd module_dir/     #子模块目录
git fetch
git merge origin/master

标题问题汇总

  • You are not currently on a branch.
    You are not currently on a branch. Please specify which branch you want to merge with. See git-pull(1) for details.
    解决办法:
首先git checkout -b temp

其次git checkout master

即可恢复到master repository的状态,然后就可以了。

切换分支失败

error: Your local changes to the following files would be overwritten by checkout:
        toutiao/baike/message/notify.thrift
Please commit your changes or stash them before you switch branches.
Aborting

解决办法:
强制切换:git checkout -f master

解决方法2

git reset --hard
git pull
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值