1GITNAMESPACES(7) Git Manual GITNAMESPACES(7)
2
3
4
6 gitnamespaces - Git namespaces
7
9 GIT_NAMESPACE=<namespace> git upload-pack
10 GIT_NAMESPACE=<namespace> git receive-pack
11
12
14 Git supports dividing the refs of a single repository into multiple
15 namespaces, each of which has its own branches, tags, and HEAD. Git can
16 expose each namespace as an independent repository to pull from and
17 push to, while sharing the object store, and exposing all the refs to
18 operations such as git-gc(1).
19
20 Storing multiple repositories as namespaces of a single repository
21 avoids storing duplicate copies of the same objects, such as when
22 storing multiple branches of the same source. The alternates mechanism
23 provides similar support for avoiding duplicates, but alternates do not
24 prevent duplication between new objects added to the repositories
25 without ongoing maintenance, while namespaces do.
26
27 To specify a namespace, set the GIT_NAMESPACE environment variable to
28 the namespace. For each ref namespace, Git stores the corresponding
29 refs in a directory under refs/namespaces/. For example,
30 GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/. You can
31 also specify namespaces via the --namespace option to git(1).
32
33 Note that namespaces which include a / will expand to a hierarchy of
34 namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under
35 refs/namespaces/foo/refs/namespaces/bar/. This makes paths in
36 GIT_NAMESPACE behave hierarchically, so that cloning with
37 GIT_NAMESPACE=foo/bar produces the same result as cloning with
38 GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar. It
39 also avoids ambiguity with strange namespace paths such as
40 foo/refs/heads/, which could otherwise generate directory/file
41 conflicts within the refs directory.
42
43 git-upload-pack(1) and git-receive-pack(1) rewrite the names of refs as
44 specified by GIT_NAMESPACE. git-upload-pack and git-receive-pack will
45 ignore all references outside the specified namespace.
46
47 The smart HTTP server, git-http-backend(1), will pass GIT_NAMESPACE
48 through to the backend programs; see git-http-backend(1) for sample
49 configuration to expose repository namespaces as repositories.
50
51 For a simple local test, you can use git-remote-ext(1):
52
53 git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
54
55
57 Anyone with access to any namespace within a repository can potentially
58 access objects from any other namespace stored in the same repository.
59 You can’t directly say "give me object ABCD" if you don’t have a ref to
60 it, but you can do some other sneaky things like:
61
62 1. Claiming to push ABCD, at which point the server will optimize out
63 the need for you to actually send it. Now you have a ref to ABCD
64 and can fetch it (claiming not to have it, of course).
65
66 2. Requesting other refs, claiming that you have ABCD, at which point
67 the server may generate deltas against ABCD.
68
69 None of this causes a problem if you only host public repositories, or
70 if everyone who may read one namespace may also read everything in
71 every other namespace (for instance, if everyone in an organization has
72 read permission to every repository).
73
74
75
76Git 1.8.3.1 11/19/2018 GITNAMESPACES(7)