git-url-parse(1) — Linux manual page

NAME | SYNOPSIS | DESCRIPTION | OPTIONS | OUTPUT | EXAMPLES | SEE ALSO | GIT | COLOPHON

GIT-URL-PARSE(1)                Git Manual               GIT-URL-PARSE(1)

NAME         top

       git-url-parse - Parse and extract git URL components

SYNOPSIS         top

       git url-parse [-c <component>] [--] <url>...

DESCRIPTION         top

       Git supports many ways to specify URLs, some of them non-standard.
       For example, git supports the scp style [user@]host:[path] format.
       This command eases interoperability with git URLs by enabling the
       parsing and extraction of the components of all git URLs.

       Any syntactically valid URL is parsed, even if the scheme is not
       one git supports for fetching or pushing.

OPTIONS         top

       -c <component>, --component <component>
           Extract the <component> component from the given Git URLs.
           <component> can be one of: scheme, user, password, host, port,
           path.

OUTPUT         top

       When --component is given, the requested component of each URL is
       printed on its own line, in the order the URLs were given. If the
       URL has no such component (for example, a port in a URL that does
       not specify one), an empty line is printed in its place.

       When --component is not given, no output is produced. The exit
       status is zero if every URL parses successfully and non-zero
       otherwise, allowing the command to be used purely as a validator.

EXAMPLES         top

       •   Print the host name:

               $ git url-parse --component host https://example.com/user/repo
               example.com

       •   Print the path:

               $ git url-parse --component path https://example.com/user/repo
               /user/repo
               $ git url-parse --component path example.com:~user/repo
               ~user/repo
               $ git url-parse --component path example.com:user/repo
               /user/repo

       •   Validate URLs without outputting anything:

               $ git url-parse https://example.com/user/repo example.com:~user/repo

SEE ALSO         top

       git-clone(1), git-fetch(1), git-config(1)

GIT         top

       Part of the git(1) suite

COLOPHON         top

       This page is part of the git (Git distributed version control
       system) project.  Information about the project can be found at 
       ⟨http://git-scm.com/⟩.  If you have a bug report for this manual
       page, see ⟨http://git-scm.com/community⟩.  This page was obtained
       from the project's upstream Git repository
       ⟨https://github.com/git/git.git⟩ on 2026-05-24.  (At that time,
       the date of the most recent commit that was found in the
       repository was 2026-05-22.)  If you discover any rendering
       problems in this HTML version of the page, or you believe there is
       a better or more up-to-date source for the page, or you have
       corrections or improvements to the information in this COLOPHON
       (which is not part of the original manual page), send a mail to
       man-pages@man7.org

Git 2.54.0.254.g6a4418          2026-05-22               GIT-URL-PARSE(1)

Pages that refer to this page: git(1)