一个目录(同一级别)中的多个存储库 - 可能吗?
我最初的问题是我有一个编写各种脚本的目录。它们中的每一个都是独立的,并且通常是一个文件长。我想对它们应用一些版本控制,但我有以下问题/要求:
- 我不想必须存储每个小脚本在单独的目录!
- 我不想将它们全部存储在一个存储库 OTOH中,因为它们完全不相关,并且:
- 其中一些文件稍后可能会增长到更多文件(然后它们将需要一个单独的目录),
- 有时我想将其中一个复制到另一台计算机(并且我想克隆整个存储库)。 其中
- 我希望从(分布式)版本控制机制中受益——至少:
- “无限”数量的修订,
- 能够在不同计算机上克隆存储库,
- 能够进行“原子”多文件提交。
可能吗?
我更喜欢在一些主流分布式 VCS 中执行此操作(使用 Mercurial 的解决方案会更好,但我还没有修复)。
编辑:该解决方案必须是免费的(至少“像啤酒一样”)和跨平台的(至少是 Win32 和 Linux)。
相关,但没有帮助:
- "two-git-repositories-in-one-directory “ - 没有发现它有帮助:接受的答案看起来像第 2 点。(上面)对我来说;当前的“社区投票”答案听起来像 1.
- “使用 Subversion 对单个文件进行版本控制” —— 2. 或 1 也太多了。
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:
- I don't want to have to store each small script in a separate directory!
- 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).
- 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:
- "two-git-repositories-in-one-directory" -- didn't find it helpful: the accepted answer looks like point 2. (above) to me; the current "community voted" answer sounds like 1.
- "Version control of single files using Subversion" -- also too much of 2. or 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这些要求对我来说似乎相当“特殊”,所以这里有一个与它们相当的解决方案 ^^
您可以在同一目录中使用两个完全不同的 VCS。即使 SVN 的两个“实例”也可能起作用:SVN 将其元数据存储在名为
.SVN
的目录中,并且(由于有关 ASP 的历史原因)可以选择使用_SVN
。目录列表应该如下所示当然,您需要隐藏或忽略每个 VCS 中的外部脚本或文件夹...
添加:
这仅占一个文件夹中的两个脚本,并且除此之外每个脚本还需要一个额外的 VCS,因此,如果您甚至考虑此路线并且需要更多存储库,请重命名每个 Metadir 并在更新之前使用脚本将其重命名回来:
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 thisOf 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:
为什么不简单地为每个(组)脚本创建一个单独的分支(在 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.
我自己考虑的另一个建议是 "使用 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.您可以创建多个隐藏存储库目录,并将符号链接
.hg
到您想要激活的任何一个。因此,如果您有两个存储库,请为它们创建目录:然后激活其中一个只需执行以下操作:
您可以轻松创建一个 bash 命令来执行此操作。因此,您可以编写类似
activate-repo production
的内容,它将运行ln -sf .hg_Production .hg
。注意:Mac 似乎不支持 ln -sf ,因此您需要执行以下操作:
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:Then to activate either of them just do:
You could easily create a bash command to do this. So instead you could write something like
activate-repo production
, which would runln -sf .hg_production .hg
.Note: Mac doesn't seem to support
ln -sf
so instead you'll need to do:我只能想到这两个轻量级版本控制系统:
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.
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)
我开始考虑在 Mercurial/git/... 上进行某种覆盖,这将保留几个“禁用”存储库元目录,比如说:
等等,然后在
hg commit FILENAME 会找到链接到
FILENAME
的特定.hgN
,然后会暂时:主要缺点是它需要我花一些时间编写该工具。或者有人知道这样的现成的吗?如果您这样做,请发布完整的答案(而不是评论),我非常愿意接受。
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:
etc., and then on
hg commit FILENAME
would find the particular.hgN
that is linked toFILENAME
, and would then temporarily: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.