Skip to main content

Git sub-command for getting a repo browser link to a git object

Project description

Git-link is a git sub-command for getting a repo-browser link to a git object. The motivation behind git-link is that it is often faster to navigate to a git object or path on the command line than it is to click your way to it through a web interface. An example using git-link’s github sources:

$ git config --add link.url
$ git config --add link.browser github

$ git link HEAD~10

$ git link v0.2.0

$ git link v0.2.0 --

Git-link can be used with : cgit, gitweb, github, github-private


Install from PyPi:

$ pip install gitlink

Or simply put git-link in your $PATH and make it executable:


Usage: git link [options] <commit|tree|blob|path|branch|tag|diff>

  -h, --help            show this help message and exit
  -v, --version         show version and exit
  -c, --clipboard       copy link to clipboard (overwrites link.clipboard)
  -u, --url <url>       repo browser url (overwrites link.url)
  -b, --browser <type>  repo browser type (overwrites link.browser)
  -s, --short <num>     truncate hashes to length (overwrites link.short)
  -r, --raw             show raw blob if possible

Repo browsers:
  github-private cgit gitweb github

  git config --add link.url <repo browser base url>
  git config --add link.browser <repo browser>
  git config --add link.clipboard false|true

  git link HEAD~10         url of 10th commit before HEAD
  git link v0.1.0^{tree}   url of tree object at tag v0.1.0
  git link master:file     url of file in branch master
  git link path/file       url of path/file in current branch
  git link devel -- path   url of path in branch devel
  git link v0.1.0          url of tag v0.1.0


Git-link needs to know the name and url of the repository browser for the repository it is being run in. This can be set through git-config or on the command line on each run:

$ git config --add link.url <repo browser url>
$ git config --add link.browser <repo browser name>
$ git config --add link.clipboard false|true  # optional
$ git config --add link.short 7  # optional
$ git link --browser <url> --name <name> --clipboard ...


See and if you are interested in adding a new repository browser. Release checklist:

  1. Run py.test.

  2. Bump version in gitlink/

  3. Update man page - make man/git-link.1.

  4. Create standalone script - make git-link.

Please make do without bringing in any external dependencies. As nice as GitPython and libgit2 are, anything that this tool needs from git can be queried using its command line interface.


Git-link is released under the terms of the Revised BSD License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlink-0.5.0.tar.gz (12.8 kB view hashes)

Uploaded source

Built Distribution

gitlink-0.5.0-py2.py3-none-any.whl (15.8 kB view hashes)

Uploaded 3 4

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page