git子模块修改文件状态 [英] git submodule modified files status

查看:92
本文介绍了git子模块修改文件状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主git文件夹树中添加了一个子模块,并且没有改变任何东西,但它显示出已修改。

  $ git status 
#分支主
#已更改,但未更新:
#(使用git add< file> ...更新将要提交的内容)
#(使用git checkout - < file> ...放弃更改在工作目录中)

#modified:example.com/soundmanager

没有更改添加到提交中(使用git add和/或git commit -a )

我试过了一个git子模块更新,但它没有做任何事情。

解决方案

git子模块的状态报告的方式在最近版本的git中已经发生了很大变化,所以您应该真正包含 git --version 以及我们能够准确帮助。

然而,在任何情况下,输出 git diff example.com/soundmanager 应该告诉你更多。如果您看到具有相同提交名称的输出,但在新版本中添加了 -dirty ,例如:

  diff --git a / example.com / soundmanager b / example.com / soundmanager 
--- a / example.com / soundmanager
+++ b / example.com/soundmanager
@@ -1 +1 @@
- 子项目提交c5c6bbaf616d64fbd873df7b7feecebb81b5aee7
+子项目提交c5c6bbaf616d64fbd873df7b7feecebb81b5aee7-dirty

...这意味着子模块中的 git status 不干净 - 试试 cd example.com/soundmanager ,然后 git status 来查看发生了什么。



<另一方面,如果您看到不同的提交版本,例如:


  diff --git a / example.com / soundmanager b / example.com / soundmanager 
index c4478af..c79d9c8 160000
--- a / example.com / soundmanager
+++ b / example.com / soundmanager
@@ -1 +1 @@
- 子项目提交c4478af032e604bed605e82d04a248d75fa5 13f7
+子项目提交c79d9c83c2864665ca3fd0b11e20a53716d0cbb0

...表示子模块的版本一个领带您从 cd cd example.com/soundmanager&& git show HEAD )与在主项目树中提交的版本不同(即,从> git rev-parse HEAD:example.com/soundmanager )。如果前者正确,则应在主项目中添加并提交新版本的子模块,如下所示:

  git add example.com/soundmanager 
git commit -m更新soundmanager子模块

另一方面,如果后者是你想要的,你可以改变子模块的版本:

  git submodule update example.com/soundmanager 


I've added a submodule in my main git folder tree and haven't changed anything but it's showing up modified. What do I do about this?

$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    modified:   example.com/soundmanager
#
no changes added to commit (use "git add" and/or "git commit -a")

I've tried a git submodule update, but it doesn't do anything.

解决方案

The way that the status of git submodules is reported has changed a lot over recent versions of git, so you should really include the output of git --version as well for us to be able to help accurately.

However, in any case, the output of git diff example.com/soundmanager should tell you more. If you see output with the same commit name, but with -dirty added to the new version, e.g.:

diff --git a/example.com/soundmanager b/example.com/soundmanager
--- a/example.com/soundmanager
+++ b/example.com/soundmanager
@@ -1 +1 @@
-Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7
+Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7-dirty

... than that means that git status in the submodule isn't clean - try cd example.com/soundmanager and then git status to see what's going on.

On the other hand, if you see different commit versions, e.g.:

diff --git a/example.com/soundmanager b/example.com/soundmanager
index c4478af..c79d9c8 160000
--- a/example.com/soundmanager
+++ b/example.com/soundmanager
@@ -1 +1 @@
-Subproject commit c4478af032e604bed605e82d04a248d75fa513f7
+Subproject commit c79d9c83c2864665ca3fd0b11e20a53716d0cbb0

... that means that the version that your submodule is at (i.e. what you see from cd example.com/soundmanager && git show HEAD) is different from the version committed in the main project's tree (i.e. what you see from git rev-parse HEAD:example.com/soundmanager). If the former is right, you should add and commit the new version of the submodule in your main project, with something like:

git add example.com/soundmanager
git commit -m "Update the soundmanager submodule"

On the other hand, if the latter is what you want, you can change the version that the submodule is at with:

git submodule update example.com/soundmanager

这篇关于git子模块修改文件状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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