最新的git submodule跟踪 [英] git submodule tracking latest

查看:156
本文介绍了最新的git submodule跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将我们的(巨大)项目转移到git上,我们正在考虑使用子模块。我们的计划是在超级项目中有三个不同的头:发布,稳定,最新。项目负责人将负责发布和稳定的分支机构。他们将根据需要移动子模块。



问题是最新的问题。我们希望超级项目最新头部(自动)跟踪所有子模块的主分支。如果它能够显示所有对子模块的提交历史,那也是非常棒的。

我看过gitslave,但它不是我们想要的。任何建议?

解决方案

https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt =noreferrer> Git 1.8.2 增加了跟踪分支的可能性。


git子模块开始学习新模式




)(与集成超级项目gitlink中记录的提交相反) > #添加子模块来跟踪master分支
git子模块add -b master [URL to Git repo];

#更新您的子模块
git子模块更新--remote

另请参阅 Vogella关于子模块的教程



请参阅 如何使现有子模块跟踪分支 (如果你有一个子模块已经存在,你现在希望跟踪一个分支)



注意:

  git submodule add -b。 [URL to Git repo]; 
^^^

请参阅 git submodule 手册页: p>


特殊值用于表示子模块中的分支应与当前存储库中当前分支的名称相同






请参阅提交b928922727d6691a3bdc28160f93f25712c565f6



子模块添加:如果给出 - 分支,将它记录在 .gitmodules




这允许您轻松记录 子模块。 .gitmodules 中的< name> .branch 选项你添加一个新的子模块。有了这个补丁,



  $ git submodule add -b< branch> <库> [<路径>] 
$ git config -f .gitmodules submodule。<路径> .branch<分支>




简化为



  $ git submodule add -b< branch> <库> [< path>] 




这意味着, p>



  $ git submodule update --remote ... 




将从您用来初始化子模块的同一分支中获取更新,这通常是您想要的。



签名:W. Trevor King






原始答案(2012年2月):

子模块是由父回购引用的单个提交。

因为它是一个Git仓库,可以通过该子模块中的 git log 访问所有提交历史记录。



因此,为了让父母自动跟踪子模块给定分支的最新提交,它需要:


  • cd in子模块
  • git fetch / pull以确保其右分支上有最新的提交

  • cd回到父级回购

  • 添加并提交以记录子模块的新提交。



gitslave (你已经看过)似乎是最合适的,包括提交操作


由于需要检查到正确的子模块分支,进行更改,提交和更改子模块,这有点令人讨厌然后进入超级项目并提交提交(或者至少记录子模块的新位置)。

其他选择是在这里详细介绍


We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject: release,stable,latest. The project leads will handle the release and stable branches. They will move the submodules as required.

The issue is the "latest" head. We would like the superproject "latest" head to track the master branches of all the submodules (automatically). And also it would be great if it would show the history of all commits to the submodule.

I have looked at gitslave, but it is not quite what we want. Any suggestions?

解决方案

Update March 2013

Git 1.8.2 added the possibility to track branches.

"git submodule" started learning a new mode to integrate with the tip of the remote branch (as opposed to integrating with the commit recorded in the superproject's gitlink).

# add submodule to track master branch
git submodule add -b master [URL to Git repo];

# update your submodule
git submodule update --remote 

See also the Vogella's tutorial on submodules.

See "How to make an existing submodule track a branch" (if you had a submodule already present you wish now would track a branch)

Note:

git submodule add -b . [URL to Git repo];
                    ^^^

See git submodule man page:

A special value of . is used to indicate that the name of the branch in the submodule should be the same name as the current branch in the current repository.


See commit b928922727d6691a3bdc28160f93f25712c565f6:

submodule add: If --branch is given, record it in .gitmodules

This allows you to easily record a submodule.<name>.branch option in .gitmodules when you add a new submodule. With this patch,

$ git submodule add -b <branch> <repository> [<path>]
$ git config -f .gitmodules submodule.<path>.branch <branch>

reduces to

$ git submodule add -b <branch> <repository> [<path>]

This means that future calls to

$ git submodule update --remote ...

will get updates from the same branch that you used to initialize the submodule, which is usually what you want.

Signed-off-by: W. Trevor King


Original answer (February 2012):

A submodule is a single commit referenced by a parent repo.
Since it is a Git repo on its own, the "history of all commits" is accessible through a git log within that submodule.

So for a parent to track automatically the latest commit of a given branch of a submodule, it would need to:

  • cd in the submodule
  • git fetch/pull to make sure it has the latest commits on the right branch
  • cd back in the parent repo
  • add and commit in order to record the new commit of the submodule.

gitslave (that you already looked at) seems to be the best fit, including for the commit operation.

It is a little annoying to make changes to the submodule due to the requirement to check out onto the correct submodule branch, make the change, commit, and then go into the superproject and commit the commit (or at least record the new location of the submodule).

Other alternatives are detailed here.

这篇关于最新的git submodule跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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