git submodule fatal: please stage your changes to .gitmodules or stash them to proceed

这篇具有很好参考价值的文章主要介绍了git submodule fatal: please stage your changes to .gitmodules or stash them to proceed。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

— 简洁版 ↓↓↓↓ —

$ rm -rf submodule/sub_project1
$ cd .git
$ vim config 

输入i 进入-- INSERT --模式,在这个模式可以编辑文件内容

$ i

删掉 submodule 中sub_project1 的相关信息
Esc键盘,退出文本输入编辑模式
输入:,再输入wq退出 config 文件,

$ cd modules
$ rm -rf submodule/sub_project1

$ cd ../../submodule
$ git submodule add gitlab.xxx.com/xxx/sub_project1.git

如果add子模块,提示'sub_project1 already exists in the index',就要

$ git rm --cached sub_project1

Please stage your changes to .gitmodules or stash them to proceed报错,删掉 .gitmodules 文件,并把修改记录添加到暂存区

$ cd ..
$ rm ./.gitmodules
$ git add .

$ cd submodule
$ git submodule add gitlab.xxx.com/xxx/sub_project1.git

— 简洁版完—

— 图文版 ↓↓↓↓ —

nuxt 项目,项目名:myProject
部分目录省略
- myProject
   - .git
   - assets
   - pages
   - submodule
      - sub_project1
      - sub_project2
   - .gitmodules
   - .gitignore
   - nuxt.config.js
   - ... ...

基于已安装git bash 的情况下,

打开myProject 文件夹所在位置,鼠标右键选择Git Bash Here

git submodule fatal: please stage your changes to .gitmodules or stash them to proceed

直接删掉submodule中的子模块,比如删掉sub_project1

$ rm -rf submodule/sub_project1
git submodule fatal: please stage your changes to .gitmodules or stash them to proceed

到.git文件夹下删掉所有相关的东西

$ cd .git

删除myProject/.git/config相关内容

$ vim config
输入i 进入-- INSERT --模式,在这个模式可以编辑文件内容
$ i
删掉submodule信息
Esc键盘,退出文本输入编辑模式
输入:,再输入wq退出 config 文件,

删除myProject/.git/modules相关内容

进入myProject/.git/modules目录,删除 sub_project1的相关数据,慎重!敲错容易误删!防止错误删除,可以到文件夹手动删除
$ cd modules
$ rm -rf submodule/sub_project1

回到submodule文件夹,git submodule add xxx(git仓库地址)

$ cd …/…/submodule
$ git submodule add gitlab.xxx.com/xxx/sub_project1.git

'sub_project1 already exists in the index'报错,用 --cached

如果直接add子模块,提示'sub_project1 already exists in the index',就要
$ git rm --cached sub_project1

Please stage your changes to .gitmodules or stash them to proceed报错,删掉 .gitmodules 文件,并把修改记录添加到暂存区

! 如果提示Please stage your changes to .gitmodules or stash them to proceed,
直接删掉.gitmodules文件,并且把删掉 .gitmodules 的记录提交到仓库的暂存区中
否则每次添加 sub_project1子模块,都会提示 'sub_project1 already exists in the index'

返回上一层目录,删掉 .gitmodules 文件
$ cd …
$ rm ./.gitmodules
$ git add .

重新进入submodule,进行添加

$ cd submodule
$ git submodule add gitlab.xxx.com/xxx/sub_project1.git文章来源地址https://www.toymoban.com/news/detail-405310.html

到了这里,关于git submodule fatal: please stage your changes to .gitmodules or stash them to proceed的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Git提交错误:Please commit your changes or stash them before you merge

    这个错误提示意味着你在进行合并操作时,存在本地修改的文件尚未被提交到版本控制系统,这些修改会被合并覆盖掉。因此,你需要在合并之前决定如何处理这些未提交的修改。 有两种处理方式: 1. 提交修改:如果你的修改是有意义的,你可以先提交这些修改,然后再进

    2024年02月03日
    浏览(33)
  • (极简解决)git commit 时出现:please enter the commit message for your changes

    很多小白当使用git commit命令后,出现了这个框,而且按其他按键都没有反应的时候,肯定会有很多小白开始慌了。 原因分析:是对commit语句不熟练,或者对日志不习惯导致的。弹出这个框(文本编辑)的原因是因为更改这个文件提交后并没有做出备注,如果使用git commit -m

    2024年02月13日
    浏览(42)
  • git提示Please commit your changes or stash them before you switch branches.

    从当前分支想要切换到另一个分支,但是由于当前的修改没有提交,所以会提示【Please commit your changes or stash them before you switch branches.】 但是自己这个分支的功能还没有开发完,去commit提交的话感觉不完整。 这时候如果要切换到其他分支的话就可以执行 git stash 这条指令的作

    2024年02月15日
    浏览(34)
  • Git 切换分支:Please commit your changes or stash them before you switch branches.(SourceTree))

    Git 切换分支的时候遇到提示:Please commit your changes or stash them before you switch branches. 意思是切换分支之前需要先提交当前的更改;但是我又不想把修改提交到当前分支,应该怎么办?这时就可以用 Git 的贮藏(git stash)功能。 在 SourseTree 里面,点击最上方的按钮就能用贮藏功能

    2024年02月04日
    浏览(45)
  • Changes to be committed: (use “git restore --staged <file>...“ to unstage)

    删除了数据库的某个表后,使用 git commit 提交到本地仓库,无论怎么提交,强制也好,总是出现如下错误: 找到该文件所在位置,备份该文件后删除它,运行 git add . 和 git commit , 运行成功后回到该文件,再把sql文件拷贝回去,重新运行 git add . 和 git commit 问题解决:

    2024年02月11日
    浏览(35)
  • git报错can‘t push refs to remote. Try running “Pull“ first to integrate to your changes

      这是我在使用git提交代码到GitHub上时遇到的一个报错,刚遇到此问题,内心充满了恐惧,不知如何解决,花了不少时间查资料,因此有必要在此记录一下,同时希望可以为读者提供一定参考。   在远程创建空仓库,然后本地写一些代码,尝试提交到远程时,出现标题所指的

    2024年02月08日
    浏览(58)
  • git报错-Your local changes to the following files would be overwritten by merge:

    有一天我在服务器拉取git仓库的代码时报错如下   大概意思就是试图合并一个分支到你的当前分支,但是在你的当前分支上,有三个 .pyc 文件有本地未提交的修改。这些修改如果进行合并操作,将会被合并过来的分支中的对应文件内容覆盖。 错误信息建议在合并之前,你需

    2024年04月10日
    浏览(38)
  • Git常见报错:Your local changes to the following files would be overwritten by merge

    1、报错原因 该报错在git pull时出现,一句话解释就是你在本地改动了代码但是还没有提交,此时再拉取最新代码,远程代码和你当前的本地代码发生冲突!(注意有冲突时才会提示,如果没有冲突,则git pull成功,因为git pull实质上就是一个远程分支merge到本地分支过程。 2、解

    2024年02月08日
    浏览(37)
  • git pull报错:error: Your local changes to the following files would be overwritten by merge:

    合作项目,之前用笔记本把代码做了一些修改、提交,修改完成。第二天忘了先 git pull 到本地,直接进行编写,突然想起忘了 pull 了,然后想用 git pull 来更新本地代码,结果报错: error: Your local changes to the following files would be overwritten by merge: 意思是我本地上新修改的代码的

    2024年02月04日
    浏览(43)
  • git pull 时提示 error: Your local changes to the following files would be overwritten by merge

    这个错误提示说明你本地有未提交的修改,但是你又尝试从远程仓库拉取更新,导致合并时出现冲突。你需要先解决冲突,再进行拉取更新操作。 有几种解决方法: 1、提交本地修改:如果你对本地修改进行了保存并且希望保留这些修改,可以先提交修改,然后再拉取更新。

    2024年02月07日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包