This article clarifies the purpose and correct usage of Git's `--end-of-options` flag, which safely terminates option parsing when passing potentially dash-prefixed arguments like revisions or URLs. It explains how Git historically repurposed `--` to separate revisions from pathspecs, making `--end-of-options` necessary to avoid ambiguity and improve script security. Support has been gradually adopted across subcommands since Git 2.24, with some commands lagging due to custom argument parsers.
Background
Git's argument parser uses `--` to separate options from pathspecs, which creates edge cases when user-controlled revisions or URLs start with a hyphen. The `--end-of-options` flag was added to align Git with POSIX option-parsing conventions and prevent option-injection bugs in automation scripts.
- Source
- Lobsters
- Published
- Jul 21, 2026 at 08:31 PM
- Score
- 7.0 / 10