Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Configuration Options

protocol.* settings

Reference for protocol.allow, protocol.<name>.allow and protocol.version: restrict which transports Git may use (file, ssh, https) and pick the wire protocol.

The protocol.* settings decide which transports Git may use to reach another repository. The names are the URL schemes: http, https, git, ssh, file and ext. Each can be set to always, never or user. They are a security tool: a hostile repository can contain submodule URLs that make Git read local files or run commands, and these settings let you refuse such transports.

protocol.version is unrelated to allowing or denying; it selects the version of Git's wire protocol (default 2).

Terminal
git config --global protocol.allow user
git config --global protocol.ext.allow never
git config --global protocol.file.allow user
git config --global protocol.version 2

Try it

Bash Denying the file transport

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Default allow and per-protocol overrides

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git config protocol.allow (always | never | user)
git config protocol.<name>.allow (always | never | user)
git config protocol.version (0 | 1 | 2)
export GIT_ALLOW_PROTOCOL=<name>:<name>:...
Name Description
protocol.<name>.allow Policy for one transport (http, https, git, ssh, file, ext). Overrides protocol.allow.
protocol.allow Policy for transports without their own setting.
always The transport may always be used.
never The transport may never be used.
user The transport may be used only for operations started by you. When GIT_PROTOCOL_FROM_USER is 0 (as set by tools that run Git on your behalf for untrusted data), it is refused.
protocol.version Wire protocol version. 2 is the default, 0 is the original, 1 adds a version line to version 0.
GIT_ALLOW_PROTOCOL Colon-separated list that, when set, replaces every config setting: listed transports are allowed, all others are denied.

Defaults when nothing is configured: http, https, git and ssh are always; file is user; ext is never. Git 2.38.1 tightened the file default for submodules after a security advisory.

Errors: a denied transport stops with fatal: transport 'file' not allowed.

Usage notes

  • Security first. Restrict ext (runs arbitrary commands) and file for untrusted repositories; CI systems that clone third-party code should set GIT_ALLOW_PROTOCOL=https:ssh.
  • file and submodules: since Git 2.38.1, git submodule add of a local path fails unless protocol.file.allow=always is set for that command. Test suites and local demos pass it via -c.
  • The setting only governs transports, not authentication; see credential.* and http.*.
  • Where to put it: the global configuration is safest; a repository could in principle enable a transport for itself, so do not rely on repository-local config for protection against untrusted repositories.
  • protocol.version matters for very old servers that mishandle version 2; set 0 as a workaround, not as a default.
  • Redirects: http.followRedirects and transport restrictions apply independently; a redirect to a denied scheme fails.
  • URL rewriting happens first: url.<base>.insteadOf can turn one scheme into another, and the policy is then checked against the final scheme.