如何跟踪未跟踪的内容?

发布于 2024-10-02 05:10:01 字数 1830 浏览 5 评论 0原文

请参阅下面的实线了解我原来的问题。

我的本地目录中有一个未跟踪的文件夹。当我运行 git status 时,我得到:

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

当我输入 git addvendor/plugins/open_flash_chart_2 然后再次尝试 git status 时,它仍然显示未跟踪。这是怎么回事?


以下是我最近半个小时的简单总结:

  • 发现我的 Github 存储库没有跟踪我的 vendor/plugins/open_flash_chart_2 插件。具体来说,没有内容,并且文件夹图标上显示绿色箭头

  • 尝试了git子模块初始化

    在 .gitmodules 中找不到路径“vendor/plugins/open_flash_chart_2”的子模块映射
    
  • 尝试git submodule add git://github.com/korin/open_flash_chart_2_plugin.gitvendor/plugins/open_flash_chart_2

    vendor/plugins/open_flash_chart_2 已存在于索引中
    
  • git状态< /p>

    已修改:vendor/plugins/open_flash_chart_2(未跟踪内容)
    
  • 在我的存储库/本地目录中寻找任何名为 .gitmodules 的文件,但找不到。

我需要做什么才能让我的子模块工作以便 git 可以开始正确跟踪?


这可能是不相关的(我把它包括在内,以防它有帮助),但每次我输入 git commit -a ,而不是我通常的 git commit -m "my comments" ,它抛出一个错误:

E325: ATTENTION
Found a swap file by the name ".git\.COMMIT-EDITMSG.swp"
         dated: Thu Nov 11 19:45:05 2010
     file name: c:/san/project/.git/COMMIT_EDITMSG
      modified: YES
     user name: San   host name: San-PC
    process ID: 4268
While opening file ".git\COMMIT_EDITMSG"
         dated: Thu Nov 11 20:56:09 2010
  NEWER than swap file!  
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

我是 Github 的新手,尽管尝试查看文档,但我还是对这些特定问题感到有点困惑。谢谢。

See below the solid line for my original question.

I have a folder in my local directory that is untracked. When I run git status, I get:

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

When I type git add vendor/plugins/open_flash_chart_2 then try git status again, it still says untracked. What's going on?


Here is a simple summary of my latest half hour:

  • Discovered that my Github repo is not tracking my vendor/plugins/open_flash_chart_2 plugin. Specifically, there's no content and it's showing a green arrow on the folder icon.

  • Tried git submodule init

    No submodule mapping found in .gitmodules for path 'vendor/plugins/open_flash_chart_2'
    
  • Tried git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

    vendor/plugins/open_flash_chart_2 already exists in the index
    
  • git status

    modified: vendor/plugins/open_flash_chart_2 (untracked content)
    
  • Hunted for any file named .gitmodules in my repository/local directory but couldn't find one.

What do I have to do to get my submodules working so git can start tracking properly?


This may be unrelated (I include it in case it helps), but every time I type git commit -a rather than my usual git commit -m "my comments", it throws up an error:

E325: ATTENTION
Found a swap file by the name ".git\.COMMIT-EDITMSG.swp"
         dated: Thu Nov 11 19:45:05 2010
     file name: c:/san/project/.git/COMMIT_EDITMSG
      modified: YES
     user name: San   host name: San-PC
    process ID: 4268
While opening file ".git\COMMIT_EDITMSG"
         dated: Thu Nov 11 20:56:09 2010
  NEWER than swap file!  
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

I am a complete newbie at Github and despite trying to go through the documentation, I'm a bit stumped by these particular problems. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

清醇 2024-10-09 05:10:01

您已将 vendor/plugins/open_flash_chart_2 添加为“gitlink”条目,但从未将其定义为子模块。实际上,您正在使用 git 子模块 使用的内部功能(gitlink 条目),但您没有使用子模块功能本身。

您可能做了这样的事情:

git clone git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2
git add vendor/plugins/open_flash_chart_2

最后一个命令就是问题所在。目录 vendor/plugins/open_flash_chart_2 最初是一个独立的 Git 存储库。通常这样的子存储库会被忽略,但是如果你告诉 git add 显式添加它,那么它将创建一个指向子存储库的 HEAD 提交的 gitlink 条目,而不是添加目录的内容。如果 git add 拒绝创建这样的“半子模块”,那可能会很好。

普通目录在 Git 中表示为树对象;树对象为它们包含的对象(通常是其他树和 blob 对象,分别是目录和文件)提供名称和权限。子模块表示为“gitlink”条目; gitlink 条目仅包含子模块 HEAD 提交的对象名称(哈希)。 gitlink 提交的“源存储库”在 .gitmodules 文件中指定(以及初始化子模块后的 .git/config 文件)。

您拥有的是一个指向特定提交的条目,而不记录该提交的源存储库。您可以通过将 gitlink 放入适当的子模块,或者删除 gitlink 并将其替换为“正常”内容(纯文件和目录)来解决此问题。

将其变成正确的子模块

vendor/plugins/open_flash_chart_2 正确定义为子模块所需的唯一一点是 .gitmodules 文件。通常(如果您尚未将其添加为裸 gitlink 条目),您只需使用 git submodule add :

git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

正如您所发现的,如果路径已存在于索引中,则这将不起作用。解决方案是暂时从索引中删除 gitlink 条目,然后添加子模块:

git rm --cached vendor/plugins/open_flash_chart_2
git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

这将使用您现有的子存储库(即不会重新克隆源存储库)并暂存 .gitmodules文件如下所示:

[submodule "vendor/plugins/open_flash_chart_2"]
    path = vendor/plugins/open_flash_chart_2
    url = git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

它还会在主存储库的 .git/config 中创建类似的条目(没有 path 设置)。

提交它,您将拥有一个合适的子模块。当您克隆存储库(或推送到 GitHub 并从那里克隆)时,您应该能够通过 git submodule update --init 重新初始化子模块。

将其替换为纯内容

下一步假设 vendor/plugins/open_flash_chart_2 中的子存储库没有任何您想要保留的本地历史记录(即您关心的只是当前的工作树)子存储库,而不是历史记录)。

如果您关心的子存储库中有本地历史记录,那么您应该在下面的第二个命令中删除子存储库的 .git 目录之前对其进行备份。 (另请考虑下面的 git 子树示例,它保留了子存储库 HEAD 的历史记录。

git rm --cached vendor/plugins/open_flash_chart_2
rm -rf vendor/plugins/open_flash_chart_2/.git # BACK THIS UP FIRST unless you are sure you have no local changes in it
git add vendor/plugins/open_flash_chart_2

这次添加目录时,不是子仓库,所以文件会正常添加。不幸的是,由于我们删除了 .git 目录,因此没有超级简单的方法可以使源存储库保持最新状态。

您可以考虑使用子树合并 相反。这样做可以让您轻松地从源存储库中提取更改,同时保持存储库中的文件“平坦”(无子模块)。第三方 git subtree 命令 是子树的一个很好的包装器合并功能。

git rm --cached vendor/plugins/open_flash_chart_2
git commit -m'converting to subtree; please stand by'
mv vendor/plugins/open_flash_chart_2 ../ofc2.local
git subtree add --prefix=vendor/plugins/open_flash_chart_2 ../ofc2.local HEAD
#rm -rf ../ofc2.local # if HEAD was the only tip with local history

稍后:

git remote add ofc2 git://github.com/korin/open_flash_chart_2_plugin.git
git subtree pull --prefix=vendor/plugins/open_flash_chart_2 ofc2 master

git subtree push --prefix=vendor/plugins/open_flash_chart_2 [email protected]:me/my_ofc2_fork.git changes_for_pull_request

git 子树 还有一个 --squash 选项,可以让您避免将源存储库的历史记录合并到您的历史记录中,但仍然可以让您提取上游更改。

You have added vendor/plugins/open_flash_chart_2 as “gitlink” entry, but never defined it as a submodule. Effectively you are using the internal feature that git submodule uses (gitlink entries) but you are not using the submodule feature itself.

You probably did something like this:

git clone git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2
git add vendor/plugins/open_flash_chart_2

This last command is the problem. The directory vendor/plugins/open_flash_chart_2 starts out as an independent Git repository. Usually such sub-repositories are ignored, but if you tell git add to explicitly add it, then it will create an gitlink entry that points to the sub-repository’s HEAD commit instead of adding the contents of the directory. It might be nice if git add would refuse to create such “semi-submodules”.

Normal directories are represented as tree objects in Git; tree objects give names, and permissions to the objects they contain (usually other tree and blob objects—directories and files, respectively). Submodules are represented as “gitlink” entries; gitlink entries only contain the object name (hash) of the HEAD commit of the submodule. The “source repository” for a gitlink’s commit is specified in the .gitmodules file (and the .git/config file once the submodule has been initialized).

What you have is an entry that points to a particular commit, without recording the source repository for that commit. You can fix this by either making your gitlink into a proper submodule, or by removing the gitlink and replacing it with “normal” content (plain files and directories).

Turn It into a Proper Submodule

The only bit you are missing to properly define vendor/plugins/open_flash_chart_2 as a submodule is a .gitmodules file. Normally (if you had not already added it as bare gitlink entry), you would just use git submodule add:

git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

As you found, this will not work if the path already exists in the index. The solution is to temporarily remove the gitlink entry from the index and then add the submodule:

git rm --cached vendor/plugins/open_flash_chart_2
git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

This will use your existing sub-repository (i.e. it will not re-clone the source repository) and stage a .gitmodules file that looks like this:

[submodule "vendor/plugins/open_flash_chart_2"]
    path = vendor/plugins/open_flash_chart_2
    url = git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

It will also make a similar entry in your main repository’s .git/config (without the path setting).

Commit that and you will have a proper submodule. When you clone the repository (or push to GitHub and clone from there), you should be able to re-initialize the submodule via git submodule update --init.

Replace It with Plain Content

The next step assumes that your sub-repository in vendor/plugins/open_flash_chart_2 does not have any local history that you want to preserve (i.e. all you care about is the current working tree of the sub-repository, not the history).

If you have local history in the sub-repository that you care about, then you should backup the sub-repository’s .git directory before deleting it in the second command below. (Also consider the git subtree example below that preserves the history of the sub-repository’s HEAD).

git rm --cached vendor/plugins/open_flash_chart_2
rm -rf vendor/plugins/open_flash_chart_2/.git # BACK THIS UP FIRST unless you are sure you have no local changes in it
git add vendor/plugins/open_flash_chart_2

This time when adding the directory, it is not a sub-repository, so the files will be added normally. Unfortunately, since we deleted the .git directory there is no super-easy way to keep things up-to-date with the source repository.

You might consider using a subtree merge instead. Doing so will let you easily pull in changes from the source repository while keeping the files “flat” in your repository (no submodules). The third-party git subtree command is a nice wrapper around the subtree merge functionality.

git rm --cached vendor/plugins/open_flash_chart_2
git commit -m'converting to subtree; please stand by'
mv vendor/plugins/open_flash_chart_2 ../ofc2.local
git subtree add --prefix=vendor/plugins/open_flash_chart_2 ../ofc2.local HEAD
#rm -rf ../ofc2.local # if HEAD was the only tip with local history

Later:

git remote add ofc2 git://github.com/korin/open_flash_chart_2_plugin.git
git subtree pull --prefix=vendor/plugins/open_flash_chart_2 ofc2 master

git subtree push --prefix=vendor/plugins/open_flash_chart_2 [email protected]:me/my_ofc2_fork.git changes_for_pull_request

git subtree also has a --squash option that lets you avoid incorporating the source repository’s history into your history but still lets you pull in upstream changes.

无妨# 2024-10-09 05:10:01

我刚刚遇到了同样的问题。原因是因为有一个子文件夹包含“.git”文件夹。删除它让 git 很高兴。

I just had the same problem. The reason was because there was a subfolder that contained a ".git" folder. Removing it made git happy.

你与清晨阳光 2024-10-09 05:10:01
  1. 我从这些新目录中删除了 .git 目录(这可以创建子模块戏剧。如果有兴趣,请谷歌它。)
  2. 然后我运行 git rm -rf --cached /the/new/directories
  3. 然后我使用 git add 重新添加了目录。来自上面的

参考 URL https://danielmiessler.com/blog/git-modified-未跟踪/#gs.W0C7X6U

  1. I removed the .git directories from those new directories (this can create submodule drama. Google it if interested.)
  2. I then ran git rm -rf --cached /the/new/directories
  3. Then I re-added the directories with a git add . from above

Reference URL https://danielmiessler.com/blog/git-modified-untracked/#gs.W0C7X6U

奢望 2024-10-09 05:10:01

指出我必须从 Chris Johansen 与 OP 的聊天中挖掘出的内容(从答案的回复中链接):

git addvendor/plugins/open_flash_chart_2 # will add gitlink, content will keep untracked

git addvendor/plugins/open_flash_chart_2/ # 注意斜杠!!!!

第二种形式将不使用gitlink添加它,并且内容是可跟踪的。 .git 目录很方便 &自动忽略。谢谢克里斯!

To point out what I had to dig out of Chris Johansen's chat with OP (linked from a reply to an answer):

git add vendor/plugins/open_flash_chart_2 # will add gitlink, content will stay untracked

git add vendor/plugins/open_flash_chart_2/ # NOTICE THE SLASH!!!!

The second form will add it without gitlink, and the contents are trackable. The .git dir is conveniently & automatically ignored. Thank you Chris!

酒解孤独 2024-10-09 05:10:01

我通过从子文件夹中删除 .git 文件解决了这个问题。

  1. 首先从子文件夹中删除 .git 文件
  2. ,然后通过运行以下代码从 git 中删除子文件夹: git rm -rf --cached your_subfolder_name
  3. 然后再次通过 git add 添加您的文件夹。命令

I solved this issue by deleting .git file from my subfolder.

  1. First delete .git file from your subfolder
  2. Then remove your subfolder from git by running this code, git rm -rf --cached your_subfolder_name
  3. Then again add your folder by git add . command
不醒的梦 2024-10-09 05:10:01

我一直使用 Peter Lada 建议的技巧,称为“假子模块”:

http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb

它在几种情况下非常有用(pe我用它来保留我所有的存储库中的 Emacs 配置,包括 elpa/el-get 包目录内所有 git 存储库的当前 HEAD,因此当某些更新破坏某些内容时,我可以轻松回滚/前进到已知的工作版本)。

I use the trick suggested by Peter Lada all the time, dubbed as "fake submodules":

http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb

It's very useful in several scenarios (p.e. I use it to keep all my Emacs config in a repository, including the current HEAD of all git repositories inside the elpa/el-get package directories, so I could easily roll back/forward to a known working version when some update breaks something).

千纸鹤带着心事 2024-10-09 05:10:01

我在一个包含许多子模块的大项目中遇到了同样的问题。
基于 Chris Johnsen 此处VonC 这里我构建了一个简短的 bash 脚本,它迭代所有现有的 gitlink 条目并将它们添加为适当的子模块。

#!/bin/bash

# Read all submodules in current git
MODULES=`git ls-files --stage | grep 160000`

# Iterate through every submodule path
while read -r MOD; do
  # extract submodule path (split line at whitespace and take string with index 3)
  ARRIN=(${MOD})
  MODPATH=${ARRIN[3]}

  # grep module url from .git file in submodule path
  MODURL=`grep "url = " $MODPATH/.git/config`
  MODURL=${MODURL##*=}

  # echo path and url for information
  echo $MODPATH
  echo $MODURL

  # remove existing entry in submodule index
  git rm --cached $MODPATH
  # add new entry in submodule index
  git submodule add $MODURL $MODPATH
done <<< "$MODULES"

这为我解决了它,我希望它有任何帮助。

I had the same problem with a big project with many submodules.
Based on the answers of Chris Johnsen here and VonC here I build a short bash script which iterates through all existing gitlink entries and adds them as proper submodules.

#!/bin/bash

# Read all submodules in current git
MODULES=`git ls-files --stage | grep 160000`

# Iterate through every submodule path
while read -r MOD; do
  # extract submodule path (split line at whitespace and take string with index 3)
  ARRIN=(${MOD})
  MODPATH=${ARRIN[3]}

  # grep module url from .git file in submodule path
  MODURL=`grep "url = " $MODPATH/.git/config`
  MODURL=${MODURL##*=}

  # echo path and url for information
  echo $MODPATH
  echo $MODURL

  # remove existing entry in submodule index
  git rm --cached $MODPATH
  # add new entry in submodule index
  git submodule add $MODURL $MODPATH
done <<< "$MODULES"

This fixed it for me, I hope it is of any help.

唐婉 2024-10-09 05:10:01

这对我来说效果很好:

git update-index --skip-worktree

如果它不适用于路径名,请尝试文件名。让我知道这是否也适合你。

再见!

This worked out just fine for me:

git update-index --skip-worktree

If it doesn't work with the pathname, try the filename. Let me know if this worked for you too.

Bye!

独木成林 2024-10-09 05:10:01

https://git-scm.com/book/en/v2/ Git-Tools-Submodules

我认为你应该阅读这篇文章来了解一些关于子模块的知识。写得很好,读起来并不需要花太多时间。

https://git-scm.com/book/en/v2/Git-Tools-Submodules

I think you should read this to learn a little about submodule. It's well-written, and it doesn't take much time to read it.

ㄖ落Θ余辉 2024-10-09 05:10:01

有同样的问题,但在这次讨论中没有解决。

我还遇到了线程开放中描述的子模块问题。

% git status          
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (untracked content)

查看差异,我发现哈希值附加了一个 -dirty :
再次阅读文档,为我解决了问题。
http://web.mit.edu/jhawk /mnt/spo/git/git-doc/user-manual.html
查看“子模块的陷阱”部分

,原因是子模块内有更改或未跟踪的内容。
我首先必须进入子模块目录,执行“git add”+“git commit”以获取子模块中跟踪的所有内容。

Then "git status" on the master stated
% git commit
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (new commits)

现在,来自子模块的这个新 HEAD 可以提交给主模块。

Had the same problem, but it was not solved in this discussion.

I hit also the submodule problem as described in the thread opening.

% git status          
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (untracked content)

Looking at the diff I recognized a -dirty appended to a hash:
Reading the docs again, solved the problem for me.
http://web.mit.edu/jhawk/mnt/spo/git/git-doc/user-manual.html
Look at section "Pitfalls with submodules"

Reason was, there were changes or untracked content within the submodule.
I first had to got to the submodule directory, do a "git add" + "git commit" to get all content tracked within the submodule.

Then "git status" on the master stated
% git commit
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (new commits)

Now this new HEAD from the submodule could be commited to the master module.

我纯我任性 2024-10-09 05:10:01

我最近在从事合同项目(视为机密)时遇到了这个问题。当然,出于安全目的,我必须运行代码的系统无法访问互联网,因此使用 Composer 和 npm 安装依赖项变得非常痛苦。

经过与我的同事深思熟虑后,我们决定直接复制粘贴我们的依赖项,而不是进行 Composer 安装或 npm 安装。

这导致我们不在 gitignore 中添加供应商和 npm_modules。这是我遇到这个问题的时候。

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

我用谷歌搜索了一下,发现了这个有用的线程。我对 Git 不是太专业,而且在工作时有点陶醉,我只是搜索了 sellers 文件夹中的所有子模块,

find . -name ".git"

这给了我一些 4-5 个带有 git 的依赖项。我删除了所有这些 .git 文件夹,瞧,它成功了。
我知道这是一种黑客行为,而且无论如何也不是一种非常令人讨厌的行为。 SO诸神啊,请原谅我!下次我保证会阅读 gitlinks 并服从强大的 Linus Tovalds。

I recently encountered this problem while working on a contract project(deemed classified). The system in which I had to run the code did not have internet access, for security purposes of course, and so installing dependencies, using composer and npm, was becoming huge pain.

After much deliberation with my colleague, we decided to just wing it and copy paste our dependencies rather than doing composer install or npm install.

This led us to NOT add vendors and npm_modules in gitignore. This is when I encountered this problem.

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

I googled this a bit and found this helpful thread on SO. Not being too much of a pro in Git, and being a little intoxicated while working on it, I just searched for all the submodules in the vendors folder

find . -name ".git"

This gave me some 4-5 dependencies that had git on them. I removed all these .git folders and voila, it worked.
I knows it's hack, and not a very geeky one anyways. O Gods of SO, please forgive me! Next time I promise to read up on gitlinks and obey O mighty Linus Tovalds.

素年丶 2024-10-09 05:10:01

这个问题已经得到解答,但我想我应该将收到这些消息时发现的内容添加到其中。

我有一个名为 playground 的存储库,其中包含许多沙盒应用程序。我通过克隆教程的存储库,将教程中的两个新应用程序添加到了 Playground 目录中。结果是新应用程序的 git 内容指向教程的存储库,而不是我的存储库。解决方案是从每个应用程序的目录中删除 .git 目录,mv 将应用程序的目录放在 playground 目录之外,然后mv 将它们返回并运行 git add .。之后就成功了。

This question has been answered already, but thought I'd add to the mix what I found out when I got these messages.

I have a repo called playground that contains a number of sandbox apps. I added two new apps from a tutorial to the playground directory by cloning the tutorial's repo. The result was that the new apps' git stuff pointed to the tutorial's repo and not to my repo. The solution was to delete the .git directory from each of those apps' directories, mv the apps' directories outside the playground directory, and then mv them back and run git add .. After that it worked.

生寂 2024-10-09 05:10:01

首先转到目录vendor/plugins/open_flash_chart_2删除


然后:

git rm --cached vendor/plugins/open_flash_chart_2  
git add .  
git commit -m "Message"  
git push -u origin master  

git status  

输出

在分支主服务器上
您的分支已更新为“origin/master”。
没有什么可提交的,工作目录干净

First go to the Directory : vendor/plugins/open_flash_chart_2 and DELETE


THEN :

git rm --cached vendor/plugins/open_flash_chart_2  
git add .  
git commit -m "Message"  
git push -u origin master  

git status  

OUTPUT

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

意犹 2024-10-09 05:10:01

就我而言,应该添加有问题的模块,而路径中不带前导斜杠 /

错误:

[submodule "/sources/meta-security"]
        path = /sources/meta-security
        url = [email protected]:yocto/meta-security.git

正确:

[submodule "sources/meta-security"]
        path = sources/meta-security
        url = [email protected]:yocto/meta-security.git

更改后以下命令解决了问题:

git submodule update --init

In my case the problematic module should have been added without leading slash / in the path.

Wrong:

[submodule "/sources/meta-security"]
        path = /sources/meta-security
        url = [email protected]:yocto/meta-security.git

Correct:

[submodule "sources/meta-security"]
        path = sources/meta-security
        url = [email protected]:yocto/meta-security.git

After the change the following command resolved the issue:

git submodule update --init
青春有你 2024-10-09 05:10:01

唯一对我有用的方法是

  • 删除该子目录中的 .git 文件夹
  • ,然后将该子目录从主目录中移出
  • git add .
  • git commit -m “清理”
  • git push
  • 再次将该子目录移回主目录
  • git add .
  • git commit -m "message" code>
  • git push

现在它可以工作了

Only thing that worked for me

  • Deleting .git folder inside that sub-directory
  • then moving that sub-directory out from main-directory
  • git add .
  • git commit -m "cleaning up"
  • git push
  • moving that sub-directory back into main-directory
  • again git add .
  • git commit -m "message"
  • git push

Now it is working

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文