English 中文(简体)
How to use Git as content distribution network
原标题:

The book Git Internal mentions about using git as peer to peer content distribution network at p50, but doesn t have much detail. Especially how to have several branches which has tracking different files. Example:

(working dir) a00.exe a01.exe b00.exe c00.exe c01.exe c02.exe

Master branch tracks all files, while branch A only tracks a00.exe and a01.exe, branch B tracks b00.exe and so on. The next commit will update a00.exe b00.exe c00.exe. How to create branches like this? Once all branches committed, can I only fetch certain branch from remote? Thanks!

最佳回答

You will need to have a script of some sort build the various branches of content for you. The basic way to do this is to add the content to the database (in your case, just by committing them to the master branch), then in a temporary index, reading in all the contents you want to have in each branch (git read-tree/git update-index), writing that tree out (git write-tree), writing a commit object (git commit-tree) and updating the branch to that new commit (git update-ref). These are all plumbing commands that are not normally used in day-to-day operations but allow you to build snapshots without having all the contents in a directory on disk at the same time.

An example script to do something like this is here:

http://github.com/schacon/gitcrazy/blob/master/update_content.rb

Here I define a number of servers that each have one or more roles ( memcache , database or webserver ). Then I can add content to a role like this:

$ update_content.rb /path/to/content file_name memcache

That will add the content to my git db, then update the branches for the servers that are affected (that have the memcache role, in this case). I can do that for multiple files for any of the roles and git will keep track of what content each server should have. Then each server can fetch their specific branch ( server/s1 , server/s2 , etc).

I m thinking of doing a quick screencast demonstrating this soon - hope the example script is helpful. It should be pretty easy to run and figure out what s going on. In the same project there is a list script that lists out what content is on which server branch.

问题回答

There was a video/talk about that topic by the git internals author scott chacon, he talks about a content distribution network for ads in some kind of mall. inspiring: http://www.techscreencast.com/language/ruby/using-git-in-ruby-applications---scott-chacon-/1431





相关问题
Best practices for Subversion and Visual Studio projects

I ve recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that s built from a cobbling-together ...

Changing username in SVN+SSH URI on the fly in working copy

I am using SVN+SSH to check out a working copy of repository from an SVN server on which all developers are members of a developer group and have full read/write permissions on the repository ...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

How to search for file in subversion server?

Is there a way to search for a file in a subversion repository? Something similar to Unix find command, with which I can find the location of a file in a repository. I know there is svn list, but ...

热门标签