一个目录(同一级别)中的多个存储库 - 可能吗?

发布于 2024-11-01 19:02:50 字数 1028 浏览 1 评论 0原文

我最初的问题是我有一个编写各种脚本的目录。它们中的每一个都是独立的,并且通常是一个文件长。我想对它们应用一些版本控制,但我有以下问题/要求:

  1. 不想必须存储每个小脚本在单独的目录
  2. 不想将它们全部存储在一个存储库 OTOH中,因为它们完全不相关,并且:
    • 其中一些文件稍后可能会增长到更多文件(然后它们将需要一个单独的目录),
    • 有时我想将其中一个复制到另一台计算机(并且我想克隆整个存储库)。
    • 其中
  3. 希望从(分布式)版本控制机制中受益——至少:
    • “无限”数量的修订,
    • 能够在不同计算机上克隆存储库,
    • 能够进行“原子”多文件提交。

可能吗?
我更喜欢在一些主流分布式 VCS 中执行此操作(使用 Mercurial 的解决方案会更好,但我还没有修复)。

编辑:该解决方案必须是免费的(至少“像啤酒一样”)和跨平台的(至少是 Win32 和 Linux)。

相关,但没有帮助:

My original problem is that I have a directory where I write various scripts. Each of them is independent of others, and usually one-file-long. I want to have some versioning applied to them, but I have the following problems/requirements:

  1. I don't want to have to store each small script in a separate directory!
  2. I don't want to store them all in one repository OTOH, as they are completely unrelated, and:
    • some of them may later grow to more files (and then they will need a separate dir),
    • I sometimes want to copy one of them to a different machine (and I want to clone the whole repo).
  3. I want to benefit from (distributed) version control mechanisms -- at least:
    • "infinite" number of revisions,
    • ability to clone repositories on different computers,
    • ability to do "atomic" multi-file commits.

Is it possible?
I'd prefer to do it in some mainstream distributed VCS (a solution using Mercurial would be preferable, but I'm not fixed).

EDIT: the solution has to be free (at least "as in beer") and cross-platform (at least Win32 & Linux).

Related, but didn't help:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

盗琴音 2024-11-08 19:02:50

这些要求对我来说似乎相当“特殊”,所以这里有一个与它们相当的解决方案 ^^

您可以在同一目录中使用两个完全不同的 VCS。即使 SVN 的两个“实例”也可能起作用:SVN 将其元数据存储在名为 .SVN 的目录中,并且(由于有关 ASP 的历史原因)可以选择使用 _SVN。目录列表应该如下所示

.SVN    // Metadata for rep1
_SVN    // Metadata for rep2
script1 // in rep1
script2 // in rep2
...

当然,您需要隐藏或忽略每个 VCS 中的外部脚本或文件夹...

添加:
这仅占一个文件夹中的两个脚本,并且除此之外每个脚本还需要一个额外的 VCS,因此,如果您甚至考虑此路线并且需要更多存储库,请重命名每个 Metadir 并在更新之前使用脚本将其重命名回来:

MOVE .SVN-script1 .SVN
svn update
MOVE .SVN .SVN-script1

These requirements seem pretty "special" to me, so here is a solution on par with them ^^

You may use two completely different VCS, in the same directory. Even two "instances" of SVN might work: SVN stores its metadata in a directory called .SVN and has (for historical reasons regarding ASP) the option to use _SVN. The Directory listing should look like this

.SVN    // Metadata for rep1
_SVN    // Metadata for rep2
script1 // in rep1
script2 // in rep2
...

Of course, you will need to hide or ignore the foreign scripts or folders from each VCS...

Added:
This only accounts for two scripts in one folder and needs one additional VCS per script beyond that, so if you even consider this route and need more repositories, rename each Metadir and use a script to rename it back before updating:

MOVE .SVN-script1 .SVN
svn update
MOVE .SVN .SVN-script1
卷耳 2024-11-08 19:02:50

为什么不简单地为每个(组)脚本创建一个单独的分支(在 git 意义上)?

您可以根据需要单独开发它们。切换到某个分支将仅显示该分支中的脚本。它有点像目录,但由版本控制系统管理。如果您稍后想要将一个分支拖入另一个存储库,您可以这样做,如果您想将两个脚本合并到一个项目中,您也可以这样做。将它们复制到不同的机器点可能是一个问题,但您可以克隆您感兴趣的分支,它应该适合您。

Why don't you simply create a separate branch (in the git sense) for each (group of) script(s)?

You can develop them individually as you please. Switching to a branch will show you only the scripts from that branch. It's sort of like directories but managed by the version control system. If you later want to pluck a branch out into another repository, you can do that and if you want to combine two scripts into a single project, you can do that as well. The copying them to the different machine point might be a problem but you can clone the branch you're interested in and you it should work for you.

素罗衫 2024-11-08 19:02:50

我自己考虑的另一个建议是 "使用 Convert 分解您的存储库”文章位于 hgtip.com。它作为“独立”解决方案失败了,但作为“mv .hgN .hg / MOVE .SVN-script1 .SVN”想法的补充可能会有所帮助。

Another proposition for my own consideration is "Using Convert to Decompose Your Repository" article on hgtip.com. It fails as a "standalone" solution, but could be helpful as an addition to the "mv .hgN .hg / MOVE .SVN-script1 .SVN" idea.

℉絮湮 2024-11-08 19:02:50

您可以创建多个隐藏存储库目录,并将符号链接 .hg 到您想要激活的任何一个。因此,如果您有两个存储库,请为它们创建目录:

.hg_production
.hg_staging

然后激活其中一个只需执行以下操作:

ln -sf .hg_production .hg

您可以轻松创建一个 bash 命令来执行此操作。因此,您可以编写类似 activate-repo production 的内容,它将运行 ln -sf .hg_Production .hg

注意:Mac 似乎不支持 ln -sf ,因此您需要执行以下操作:

rm .hg; ln -s .hg_production .hg

You can create multiple hidden repository directories and symlink .hg to whichever one you want to be active. So if you have two repositories, create directories for them:

.hg_production
.hg_staging

Then to activate either of them just do:

ln -sf .hg_production .hg

You could easily create a bash command to do this. So instead you could write something like activate-repo production, which would run ln -sf .hg_production .hg.

Note: Mac doesn't seem to support ln -sf so instead you'll need to do:

rm .hg; ln -s .hg_production .hg
吐个泡泡 2024-11-08 19:02:50

我只能想到这两个轻量级版本控制系统:

1) 使用 Dropbox 进行 Pack-Rat 升级,以保留自动备份的每个文件的完整版本历史记录,并可以与多个 Dropbox 用户共享:https://www.dropbox.com/help/113

如果您有多台计算机由同一用户管理(你),同步将是自动的。此外,如果机器位于同一 LAN 中,Dropbox 足够智能,可以通过本地网络同步文件,因此不必担心大文件。

2) 使用 Mac OS X Lion 的“版本”感知文本编辑器。我希望在 Lion 发布时,TextMate、Coda 和其他流行的 Mac 代码编辑器能够更新以支持此功能。

I can only think of these two lightweight versioning systems:

1) Using Dropbox with the Pack-Rat upgrade, to keep a full history of versions for each file automatically backed up and with the possibility to be shared with multiple Dropbox users: https://www.dropbox.com/help/113

If you have multiple machines managed by the same user (you), the synching would be automatic. Also if the machines are in the same LAN, Dropbox is smart enough to sync the files over the local network, so big files shouldn't be a worry.

2) Using a 'Versions' aware text editor for Mac OS X Lion. I'd expect TextMate, Coda and other popular Mac code editors to be updated to support this feature when Lion is released.

守护在此方 2024-11-08 19:02:50

1 和 2 之间的折衷怎么样?您是否可以将它们捆绑到松散相关的组中,例如“数据库”、“备份”等,然后为每个组创建一个文件夹+存储库,而不是为每个脚本创建一个文件夹+存储库?然后,如果您在另一台计算机上克隆存储库,则只会拉取较少数量的不相关文件。 (带宽/驱动器空间真的是一个问题吗?)对我来说,这听起来比迄今为止的所有其他建议都要简单。

(从技术上讲,这种方法满足您的要求,因为(1)每个脚本都不在自己的目录中,(2)并非所有脚本都在同一个存储库中,(3)您可以使用任何流行的 DVCS 轻松地做到这一点。:D)

How about a compromise between 1 and 2? Instead of a folder+repo for each script, can you bundle them into loosely related groups, such as "database", "backup", etc. and then make one folder+repo for each group? Then if you clone a repo on another machine, you're only pulling down a smaller number of unrelated files. (Is the bandwidth/drivespace really a concern?) To me, this sounds WAAAY simpler than all of the other suggestions so far.

(Technically this approach meets your requirements because (1) each script isn't in its own directory, (2) not all scripts are in the same repository, and (3) you can easily do this with any popular DVCS. :D)

厌倦 2024-11-08 19:02:50

更新(2016):显然,一个名叫 Cosmin Apreutesei 的人创建了一个名为 multigit,这似乎实现了我在这个问题中的愿望!如果您读过它,非常感谢 Cosmin!我今年开始使用您的工具,并且发现它太棒了


我开始考虑在 Mercurial/git/... 上进行某种覆盖,这将保留几个“禁用”存储库元目录,比如说:

.hg1/
.hg2/
.hg3/

等等,然后在 hg commit FILENAME 会找到链接到 FILENAME 的特定 .hgN,然后会暂时:

mv .hgN .hg
hg commit FILENAME
mv .hg .hgN

主要缺点是它需要我花一些时间编写该工具。或者有人知道这样的现成的吗?如果您这样做,请发布完整的答案(而不是评论),我非常愿意接受。

UPDATE (2016): Apparently, a guy named Cosmin Apreutesei created a tool named multigit, which seems to implement what I wished for in this question! If you ever read it, thanks a lot Cosmin! I've started using your tool this year and find it awesome.


I'm starting to think of some kind of an overlay over Mercurial/git/... which would keep a couple "disabled" repository meta-directories, let's say:

.hg1/
.hg2/
.hg3/

etc., and then on hg commit FILENAME would find the particular .hgN that is linked to FILENAME, and would then temporarily:

mv .hgN .hg
hg commit FILENAME
mv .hg .hgN

The main disadvantage is that it would require me to spend some time writing the tool. Or does anybody know of some ready-made one like this? If you do, please post as a full-featured answer (not a comment), I'm more than willing to accept it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文