git子模块在删除后不起作用 [英] git submodule not working after deleting

查看:169
本文介绍了git子模块在删除后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置子模块的项目。
一位同事不小心删除了目标文件夹,而是创建了一个符号链接(指向项目文件夹外部),提交它。



现在我无法即使在删除链接并创建一个空目录后,也可以恢复子模块。
.gitmodule和.git / config没有改变。
git submodule add和git submodule init不会做任何事情。

我无法恢复有问题的提交,因为它还包含很多其他更改。



如何解决这个问题?

解决方案

在修改之前将它们存储在repo 中的目录恢复。



重新创建这些子模块根目录不起作用。 p>

会有什么作用:

  git checkout master @ {2 days ago }  -  path / to / submodule / directory 

(如果您知道子模块在2天前工作,例如)

这将恢复一个空目录,它实际上是一个 special entry 在索引中。

然后一个 git submodule update --init 将会恢复它的内容。


I have a project with a submodule set up. A colleague by accident deleted the target folder and made a symlink instead (pointing outside the project folder), committing it.

Now I'm not able to restore the submodule anymore, even after deleting the link and creating an empty directory. .gitmodule and .git/config haven't changed. git submodule add and git submodule init don't do anything.

I can't revert the problematic commit, because it also contains a lot of other changes.

How can this be fixed?

解决方案

You need to restore the directories as they were stored in your repo before the change.

Re-creating those submodule root directory won't work.

What will work is:

git checkout master@{2 days ago} -- path/to/submodule/directory

(if you know the submodule was working 2 days ago, for instance)

That will restore an empty directory which actually is a special entry in the index.

Then a git submodule update --init will restore its content.

这篇关于git子模块在删除后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆