Concurrent and multiple commits git access
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?
2 Solutions collect form web for “Concurrent and multiple commits git access”
For browsing commits, you don’t actually “check out” any particular file, you just extract objects as needed. This works in a
--bare repo, where there is no working directory (and “push”-able repos are almost all
To simulate this in the shell, try:
git ls-tree --name-only HEAD~3 git show HEAD~3:README # assuming README is one of the listed files
If you leave out
--name-only you’ll see the raw SHA1 values for each tree-or-blob in the named commit. A tree is a sub-directory, so:
git ls-tree HEAD~3 xdiff/
will get you the contents of the directory
xdiff, and so on. A blob is a file, so:
git cat-file -p <sha-1>
will get you the contents of the file (like “git show” with the appropriate path). In fact, you can use
git show to read the directories too:
git show HEAD~3:""
is a lot like
git ls-tree --name-only HEAD~3 (there are some minor differences, try these out to see).
(Some tree-browsers actually run git commands, some use various libraries or other direct-access-to-raw-repo methods. Using commands is not as efficient but means you immediately adapt to new formats, such as the v4 pack file format.)
If you want to have multiple browseable source tree, you can’t do it on command line from a working directory.
But you can invoke
$ gitk --all
to show all the branches. Then you can browse the commits and files in it. But if you’re accessing it on a server through ssh, you’ll need to tunnel X too.
But if you are OK with installing something that does not “default git”, take a look at GitList.