GITNAMESPACES(7)
π gitnamespaces(7) π
okay so bestie, this is the gitnamespaces(7) page from the Git manual, and it is lowkey one of those tiny pages with big main-character energy. We're talking namespaces, refs, and security tea β. Let's go π
π NAME π
gitnamespaces - Git namespaces
πΈ SYNOPSIS πΈ
GIT_NAMESPACE=<namespace> git upload-pack
GIT_NAMESPACE=<namespace> git receive-pack
β¨ DESCRIPTION β¨
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as git-gc(1). Slay.
Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do. No cap.
To specify a namespace, set the GIT_NAMESPACE environment variable to the namespace. For each ref namespace, Git stores the corresponding refs in a directory under refs/namespaces/. For example, GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/. You can also specify namespaces via the --namespace option to git(1). Cute.
Note that namespaces which include a / will expand to a hierarchy of namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under refs/namespaces/foo/refs/namespaces/bar/. This makes paths in GIT_NAMESPACE behave hierarchically, so that cloning with GIT_NAMESPACE=foo/bar produces the same result as cloning with GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar. It also avoids ambiguity with strange namespace paths such as foo/refs/heads/, which could otherwise generate directory/file conflicts within the refs directory. The way that works? Obsessed.
git-upload-pack(1) and git-receive-pack(1) rewrite the names of refs as specified by GIT_NAMESPACE. git-upload-pack and git-receive-pack will ignore all references outside the specified namespace. Bye to the outside refs π.
The smart HTTP server, git-http-backend(1), will pass GIT_NAMESPACE through to the backend programs; see git-http-backend(1) for sample configuration to expose repository namespaces as repositories. Very demure, very mindful.
For a simple local test, you can use git-remote-ext(1):
git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
π‘οΈ SECURITY π‘οΈ
Big serious moment, bestie. The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository. Periodt. π
The known attack vectors are as follows:
- The victim sends
"have"lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object IDXto steal and sends a ref toX, but isnβt required to send the content ofXbecause the victim already has it. Now the victim believes that the attacker hasX, and it sends the content ofXback to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref toXin the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to"merge"Xinto a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.) - As in #1, the attacker chooses an object ID
Xto steal. The victim sends an objectYthat the attacker already has, and the attacker falsely claims to haveXand notY, so the victim sendsYas a delta againstX. The delta reveals regions ofXthat are similar toYto the attacker.
π GIT π
Part of the git(1) suite. Iconic behavior, honestly.
mwah π stay slay, bestie π«Ά β this page came from Git 2.56.0, dated 2026-09-27.
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms