2

There doesn't seem to be an obvious way for concurrent access of a single git repo. E.g., if one user wants to checkout commit A, and another commit B, the only way I can think of of doing that is having clones.

That's fine for developing, of course - each user is expected to have a clone - but I can't imagine that it'd work nicely when you're using a repo with a server, and want to allow users to browse different commits. You'd need roughly as many clones on the server-side as there might be users.

And yet Github does just that. How does Github do it, or how might someone else, without using a large number of clones, and preferably also without many of the IO-expensive checkout operations?

4

2 に答える 2

3

コミットを参照する場合、実際には特定のファイルを「チェックアウト」するのではなく、必要に応じてオブジェクトを抽出するだけです。これは、作業ディレクトリ--bareないリポジトリで機能します(「プッシュ」可能なリポジトリはほとんどすべてです)。--bare

シェルでこれをシミュレートするには、次を試してください。

git ls-tree --name-only HEAD~3
git show HEAD~3:README          # assuming README is one of the listed files

--name-only省略した場合、名前付きコミットの各ツリーまたはブロブの生の SHA1 値が表示されます。ツリーはサブディレクトリなので、次のようになります。

git ls-tree HEAD~3 xdiff/

ディレクトリの内容などを取得xdiffします。BLOB はファイルなので、次のようになります。

git cat-file -p <sha-1>

ファイルの内容を取得します (適切なパスを指定した "git show" など)。実際、git showディレクトリの読み取りにも使用できます。

git show HEAD~3:""

よく似git ls-tree --name-only HEAD~3ています(いくつかの小さな違いがあります。これらを試してみてください)。

(実際に git コマンドを実行するツリー ブラウザもあれば、さまざまなライブラリやその他の raw リポジトリへの直接アクセス メソッドを使用するツリー ブラウザもあります。コマンドを使用することはそれほど効率的ではありませんが、v4 パック ファイル形式などの新しい形式にすぐに適応することを意味します。 )

于 2013-09-18T18:38:05.053 に答える
0

複数のブラウズ可能なソース ツリーが必要な場合、作業ディレクトリからコマンド ラインで実行することはできません。

ただし、次の方法で呼び出すことができますgitk

$ gitk --all

すべてのブランチを表示します。次に、その中のコミットとファイルを参照できます。ただし、ssh を介してサーバー上でアクセスしている場合は、X もトンネリングする必要があります。

しかし、「デフォルトの git」ではないものをインストールしても問題ない場合は、GitListを見てください。

于 2013-09-18T18:42:11.210 に答える