SVN 外部有 GIT 替代品吗?
我目前使用 SVN 来管理 jboss 服务器配置,并且我需要在每个工作副本中拥有相同子目录的多个副本,但引用服务器上的相同目录,以便当我更改某些文件时,每个副本都会获得更新。
示例:
- /server/bin (共享)
- /server/node-01 (存储库 /server/node 的副本)
- /server/node-02 (存储库 /server/node 的副本)
是否可以使用 git 实现相同的目的?我在(许多)类似问题中找不到明确的答案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我所知道的最好的近似是 git-submodule [1]。
您可以定义子存储库,并让“父”存储库在概念上包含一个哈希,指定每个子存储库应具有的确切修订版本。
当您的 HEAD 在子存储库中移动时,“git status”和“git diff”会将其报告为父存储库中的哈希更改。
不幸的是,git 子模块有点笨重:
当您拉入父存储库时,它不会自动更新子存储库。相反,子存储库将显示为好像您已进行本地更改(将其新位置恢复到原来的位置)。
在拉取/合并父存储库后,每次都必须显式调用“git submodule update”(当然,或者编写脚本)。
这也意味着父模块上的“git rebase”和其他操作在子模块存在的情况下无法正常工作。但您确实可以对这里的行为进行细粒度的控制,因此没有什么是您无法解决的。
[1] http://kernel.org/pub/software/ scm/git/docs/git-submodule.html
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