排除子项目提交Git [英] Exclude Subproject commit Git

查看:125
本文介绍了排除子项目提交Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何排除Subproject commit ....我没有在子模块中进行任何更改,仅从远程存储库中提取更改!我认为在创建子模块时,我在主存储库中提交了一些不需要的东西.有什么想法吗?

How can I exclude Subproject commit .... I changed nothing in the submodule, only pull changes from remote repository! I think I commited something unneeded in the main repository, when created submodule. Any ideas?

1)当我在主存储库中创建子模块 git diff 时,也显示了

1) When I created submodule git diff in main repository also showed

submodule-path:
    Subproject commit 5a8162ff9a602deb96956854346988e1ee45672e

我犯了这个

2)然后有人提交了子模块,因此它具有以下日志

2) then someone commited to submodule, so it has the following log

2ff89a2bfcaa0 last commit
5a8162ff9a602d  first commit

3)我更新了子模块

git submodule update --remote --merge

4)现在显示 git status

modified:   submodule-path (new commits)

但是我没有在子模块中进行任何更改,仅拉出了最后的远程更改!我需要这最后的改变

But I changed nothing in the submodule, only pull last remote changes! And I need this last changes

git diff 显示

diff --git a/submodule-path b/submodule-path
index 5a8162f..2ff89a2 160000
--- a/submodule-path
+++ b/submodule-path
@@ -1 +1 @@
-Subproject commit 5a8162ff9a602deb96956854346988e1ee45672e
+Subproject commit 2ff89a2bfcaa014885a70b0da86e997ecd8d0688

推荐答案

更新:

这不是错误.子模块就是以这种方式工作的.

This is NOT an error. The submodules just work in this way.

主存储库不跟踪子模块的文件.它仅跟踪子模块的url和提交ID(子模块在特定点的状态).

The main repo doesn't track the submodule's files. It only tracks the submodule's url and commit id (the submodule's state at a specific point).

Pro Git

尽管sbmodule DbConnector是工作目录中的子目录,但是Git会将其视为子模块,并且不在该目录中时也不会跟踪其内容.相反,Git将其视为来自该存储库的特定提交.

Although sbmodule DbConnector is a subdirectory in your working directory, Git sees it as a submodule and doesn’t track its contents when you’re not in that directory. Instead, Git sees it as a particular commit from that repository.

由于使用git submodule update更新了模块,因此必须进行更改(实际上是更新的提交ID).如果您不想更新子模块的跟踪,只需在开始时不使用git submodule update,或放弃更改.

Since you updated the module with git submodule update, you have to stage the change (in fact, the updated commit id). If you don't wanna update the tracking of submodules, just don't use git submodule update at the beginning, or just discard the change.

很可能子模块是HEAD分离的.进入子模块,重置子模块以修复HEAD分离状态.

It's very likely that the submodule is HEAD detached. Go in the submodule, reset the submodule to fix the HEAD detached status.

# Do this in the submodule
git reset --hard origin/master

然后将子模块更新为最新的提交.

Then update the submodule to the latest commit.

# run in the project's root, not the submodule's
git submodule update --remote --merge

这篇关于排除子项目提交Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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