前言
由于笔者本身也是一个git小白,git使用的不太熟练,可能就会add,commit,push这种常见的,所以在碰见一些错误或是一些特定场景下一些好用的操作,都会在此blog中进行分享。若文章中有理解误区或者解释不清的情况,还请大家多批评指正!
问题:
-
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文件的差异,可以看见绿色的那块就是我添加的内容