Multiple repositories in one directory (same level) - is it possible?

前端 未结 7 631
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 08:12

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 ap

相关标签:
7条回答
  • 2021-02-06 08:27

    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.

    0 讨论(0)
  • 2021-02-06 08:30

    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.

    0 讨论(0)
  • 2021-02-06 08:35

    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
    
    0 讨论(0)
  • 2021-02-06 08:35

    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)

    0 讨论(0)
  • 2021-02-06 08:36

    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.

    0 讨论(0)
  • 2021-02-06 08:46

    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.

    0 讨论(0)
提交回复
热议问题