Git小白报错经验汇总详解(updating)

前言

由于笔者本身也是一个git小白,git使用的不太熟练,可能就会add,commit,push这种常见的,所以在碰见一些错误或是一些特定场景下一些好用的操作,都会在此blog中进行分享。若文章中有理解误区或者解释不清的情况,还请大家多批评指正!

问题:

  1. warning: 正在添加嵌入式 git 仓库:src/teb_local_planner
    提示:You've added another git repository inside your current repository.
    提示:Clones of the outer repository will not contain the contents of
    提示:the embedded repository and will not know how to obtain it.
    提示:If you meant to add a submodule, use:
    提示:
    提示:	git submodule add <url> src/teb_local_planner
    提示:
    提示:If you added this path by mistake, you can remove it from the
    提示:index with:
    提示:
    提示:	git rm --cached src/teb_local_planner
    提示:
    提示:See "git help submodule" for more information.
    

当我在我的本地仓库中下载一些外部官方库文件夹的时候,如果我想add到暂存区,就会报这个warning。

解决方法:首先删除仓库索引

我的是文件夹就是这个格式
git rm -f --cached src/teb_local_planner/
如果你的是文件,格式为
git rm -f --cached src/teb_local_planner/

接下来添加仓库索引

url为你这个源码仓库的地址
git submodule add <url>
比如我当时是git clone https://github.com/rst-tu-dortmund/teb_local_planner.git下载的teb_local_planner这个文件夹,所以我添加仓库索引就是:
git submodule add https://github.com/rst-tu-dortmund/teb_local_planner.git

再然后我们看一下status

在这里插入图片描述

我们再重新git add一下,然后进行commit和push操作就可以了

git add .
git commit -m "add teb_local_planner"
git push

如果要拉取或者是更新这个子模块

git submodule update --init --recursive

经验

1、当我们在push代码前想看看本地仓库和远程仓库的差异来决定要不要把修改的文件push上去时,可以使用git diff操作

eg:查看git status

在这里插入图片描述

我有两个文件进行了修改,于是我用git diff <文件路径>操作查看本地仓库与远程仓库的内容变化

在这里插入图片描述

查看control.sh文件的差异,可以看见绿色的那块就是我添加的内容

持续更新…

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值