SVN Externals有没有GIT的替代品? [英] Is there an GIT alternative for SVN Externals?

查看:492
本文介绍了SVN Externals有没有GIT的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用SVN来管理jboss服务器配置,并且我需要在每个工作副本中拥有相同子目录的多个副本,但是引用服务器上的相同目录,以便当我更改某个文件时,每个副本都获得更新。
$ b

示例:


  • / server / bin(共享)

    li>
  • / server / node-01(资源库/服务器/节点的副本)

  • / server / node-02



使用git可以达到相同的效果吗?我在(maney)类似的问题中找不到明确的答案。

解决方案

我知道的最好的近似是git-submodule [b]

您可以定义子存储库,并让父存储库从概念上包含一个散列,指定每个子存储库应具有的确切修订版本。



当你的HEAD在子仓库中移动时,git status和git diff会报告它在父仓库中的散列变化。



不幸的是,git子模块有点笨重:


  • 当你拉入父仓库时,它不会自动更新儿童回购。相反,子回购将显示为您已经进行了本地更改(将新位置恢复到原来的位置)。

  • 每次调用git submodule update(或者编写它的脚本,当然是),然后再拉取/合并父回购。




<这也意味着在子模块的存在下,git rebase和其他对父项的操作也不起作用。但是你对这里的行为有很好的控制,所以没有什么可以解决的。


$ b

[1] http://kernel.org/pub/software/scm/git/docs/git-submodule.html


I currently use SVN to manage jboss server configurations and i need to have several copies of the same sub-directory in each working copy, but referencing the same directory on the server so that when i change some file, every copy gets the update.

Example:

  • /server/bin (shared)
  • /server/node-01 (copy of repository /server/node)
  • /server/node-02 (copy of repository /server/node)

Is it possible to achieve the same using git? I could not find a definitive answer in the (maney) similar questions.

解决方案

The best approximate I know of is git-submodule [1].

You can define sub-repositories and have the "parent" repository conceptually contain a hash specifying the exact revision each sub-repository should have.

When your HEAD moves in the sub-repository, "git status" and "git diff" will report that as a hash change in the parent repo.

Unfortunately, git submodules are a bit clunky:

  • When you pull in the parent repo, it will not automatically update the child repos. Instead, the child repos will appear as though you've made local changes (that revert their new position back to where they were).

  • You have to explicitly call "git submodule update" every time (or script it, of course) after you pull/merge the parent repo.

This also means that "git rebase" and other operations on the parent do not work as well in the presence of submodules. But you do have fine-grained control over the behavior here, so there's nothing you cannot work around.

[1] http://kernel.org/pub/software/scm/git/docs/git-submodule.html

这篇关于SVN Externals有没有GIT的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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