{"id":13646433,"url":"https://github.com/sshaw/git-link","last_synced_at":"2025-05-15T15:05:39.968Z","repository":{"id":12000598,"uuid":"14579096","full_name":"sshaw/git-link","owner":"sshaw","description":"Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location","archived":false,"fork":false,"pushed_at":"2025-02-14T12:40:16.000Z","size":162,"stargazers_count":423,"open_issues_count":24,"forks_count":79,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-31T20:05:28.884Z","etag":null,"topics":["aws-codecommit","azure-devops","bitbucket","codeberg","dired","emacs","git","github","gitlab","magit","sourcegraph","sourcehut","spacemacs","tramp","urls"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-21T05:53:03.000Z","updated_at":"2025-03-26T00:41:29.000Z","dependencies_parsed_at":"2024-01-14T10:00:05.877Z","dependency_job_id":"2d7ba96f-4106-4b49-b217-a2066197f1be","html_url":"https://github.com/sshaw/git-link","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fgit-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fgit-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fgit-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fgit-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshaw","download_url":"https://codeload.github.com/sshaw/git-link/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-codecommit","azure-devops","bitbucket","codeberg","dired","emacs","git","github","gitlab","magit","sourcegraph","sourcehut","spacemacs","tramp","urls"],"created_at":"2024-08-02T01:02:55.564Z","updated_at":"2025-04-07T21:09:11.600Z","avatar_url":"https://github.com/sshaw.png","language":"Emacs Lisp","readme":"# git-link\n\n[![MELPA](http://melpa.org/packages/git-link-badge.svg)](http://melpa.org/#/git-link)\n[![Build Status](https://github.com/sshaw/git-link/workflows/CI/badge.svg)](https://github.com/sshaw/git-link/actions)\n\nInteractive Emacs functions that create URLs for files and commits in GitHub/Bitbucket/GitLab/... repositories.\n\n`git-link` returns the URL for the current buffer's file location at the current line number or active region.\n\n`git-link-commit` returns the URL for the commit at point.\n\n`git-link-homepage` returns the URL for the repository's homepage.\n\nURLs are added to the kill ring.\n\n## Usage\n\nFunctions can be called interactively (`M-x git-link`) or via a key binding of your choice. For example:\n```el\n(global-set-key (kbd \"C-c g l\") 'git-link)\n```\n\nWith a single prefix argument prompt for the remote's name. Defaults to `\"origin\"`.\n\nWith a double prefix argument invert the value of `git-link-use-commit`.\n\nWith a prefix argument of `-`, generate a link without line numbers.\n\nWorks with Dired, Magit, VC revisions, and Tramp too.\n\n### Settings\n\nGlobal setting are elisp variables. They can be set directly or via `M-x customize`.\n\nLocal settings are managed via the repository's git configuration. They can be set via:\n\n```\ngit config --local --add setting value\n```\n\nLocal settings have precedence over global settings.\n\n#### Global\n\n##### `git-link-default-remote`\n\nName of the remote to link to, defaults to `nil`.\n\n##### `git-link-default-branch`\n\nName of the remote branch to link to, defaults to the current branch.\n\n##### `git-link-open-in-browser`\n\nIf `t` also open the link via `browse-url`. To use an alternate function set to\nthat function's symbol. Defaults to `nil`.\n\n##### `git-link-use-commit`\n\nIf non-`nil` use the latest commit's hash in the link instead of the branch name, defaults to `nil`.\n\n##### `git-link-use-single-line-number`\n\nIf `nil` line numbers are only added when the selection contains more than 1 line, defaults to `t`.\n\nNote that `git-link` will exclude line numbers when invoked with the `-` prefix argument.\n\n##### `git-link-add-to-kill-ring`\n\nIf `t` the link will be added to the kill-ring, defaults to `t`\n\n##### `git-link-consider-ssh-config`\n\nIf `t` consider ssh configuration file for resolving the remote's hostname. If there's a match (using `ssh -G`),\nthe link will be generated to the matching host instead of the remote's host. Defaults to `nil`.\n\n#### Local\n\n##### `git-link.remote`\n\nName of the remote to link to.\n\n##### `git-link.branch`\n\nName of the remote branch to link to.\n\n### Supported Services\n\n* [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/)\n* [AWS CodeCommit](https://aws.amazon.com/codecommit/)\n* [Bitbucket](http://bitbucket.com)\n* [Codeberg](https://codeberg.org/)\n* [cgit](https://wiki.archlinux.org/title/Cgit)\n* [GitHub](http://github.com)\n* [GitLab](https://gitlab.com)\n* [Gitea](https://about.gitea.com/)\n* [Gitorious](http://gitorious.org)\n* [GoogleSource](https://googlesource.com)\n* [Savannah](https://git.savannah.gnu.org/cgit)\n* [Sourcegraph](https://sourcegraph.com)\n* [sourcehut](https://sourcehut.org)\n\n### Git Timemachine\n\nIf [`git-timemachine-mode`](https://codeberg.org/pidu/git-timemachine)\nis active `git-link` generates a URL for the version of the file being\nvisited.\n\n### cgit and Gitea\n\ngit-link comes with functions for linking to repositories hosted by these services but, because they're self-hosted there is no default URL to match.\nTo make git-link work with these you must configure your URLs to use the appropriate matching function.\n\n#### cgit\n\n```el\n(eval-after-load 'git-link\n '(progn\n   (add-to-list 'git-link-remote-alist\n     '(\"your-cgit\\\\.example\\\\.com\" git-link-cgit))\n   (add-to-list 'git-link-commit-remote-alist\n     '(\"your-cgit\\\\.domain\\\\.tld\" git-link-commit-cgit))))\n```\n\n#### Gitea\n\n```el\n(eval-after-load 'git-link\n '(progn\n   (add-to-list 'git-link-remote-alist\n     '(\"your-gitea\\\\.example\\\\.com\" git-link-gitea))\n   (add-to-list 'git-link-commit-remote-alist\n     '(\"your-gitea\\\\.domain\\\\.tld\" git-link-commit-gitea))))\n```\n\n### Sourcegraph\n\nTo link to files on a Sourcegraph server add a git remote pointing to the repository's Sourcegraph page:\n```\ngit remote add sourcegraph https://sourcegraph.com/github.com/sshaw/copy-as-format\n```\n\nLinks can be generated by [specifying `sourcegraph` as your remote](#usage) when calling the desired link function or\nby [setting `sourcegraph` as the default remote](#settings).\n\n**Note** that the remote can be named anything but its URL's host must match what's in the associated link function's alist.\nThis defaults to `\"sourcegraph\"` but can be changed. See [Building Links and Adding Services](#building-links-and-adding-services).\n\nURLs with ports or an http scheme will not work. It's a trivial fix so if it's a problem for you please open an issue.\n\n### [Emacs Transient](https://www.gnu.org/software/emacs/manual/html_mono/transient.html) Support\n\nAn optional Transient interface (magit-like menu) is provided via `git-link-transient.el`. To enable you need to have\n`transient` installed as a dependency.\n\nTo enable `(require 'git-link-transient)` and call `git-link-dispatch` to show the menu.\n\n\n### Building Links and Adding Services\n\n`git-link-remote-alist` is an alist containing `(REGEXP FUNCTION)`\nelements. The FUNCTION creates URLs for file on remote host names that\nmatch the REGEXP. To add (or modify) how URLs are created for a given\nhost, add appropriate elements to this list.\n\nAs an example, one of the default elements in this alist is\n`(\"gitlab\" git-link-gitlab)`. So the `git-link-gitlab` function\nwill be used to create URLs to files in remotes that match the\n*regexp* `\"gitlab\"`.  That would cover common Gitlab host URLs like\n*\"gitlab.com\"*, *\"gitlab.example.com\"* and *\"gitlab.example.org\"*.\n\n`git-link-commit-remote-alist` is also an alist containing `(REGEXP\nFUNCTION)` elements. Here, the FUNCTION creates URLs to the commit\npages, for remote hosts matching REGEXP.\n\nIf you use a self-hosted version of one of the supported services, but\nyour remote URL does match with the defaults, you can configure these\nlink function alists.  For example, for a GitHub Enterprise instance\nat `gh.example.com`, you could add the following to your `.emacs`\nfile:\n\n```el\n(eval-after-load 'git-link\n '(progn\n   (add-to-list 'git-link-remote-alist\n     '(\"gh\\\\.example\\\\.com\" git-link-github))\n   (add-to-list 'git-link-commit-remote-alist\n     '(\"gh\\\\.example\\\\.com\" git-link-commit-github))))\n```\n\nThe `git-link` signature is:\n\n`HOSTNAME DIRNAME FILENAME BRANCH COMMIT START END`\n\n* `HOSTNAME` hostname of the remote\n* `DIRNAME` directory portion of the remote\n* `FILENAME` source file, relative to `DIRNAME`\n* `BRANCH` active branch, may be `nil` if the repo's in \"detached HEAD\" state\n* `COMMIT` SHA of the latest commit\n* `START` starting line number\n* `END`  ending line number, `nil` unless region is active\n\nThe `git-link-commit` signature is:\n\n`HOSTNAME DIRNAME COMMIT`\n\n* `HOSTNAME` hostname of the remote\n* `DIRNAME` directory portion of the remote\n* `COMMIT` SHA of the commit\n\n### See Also\n\n* [copy-as-format](https://github.com/sshaw/copy-as-format)\n* [output-as-format](https://github.com/sshaw/output-as-format)\n\n### TODO\n\n* More tests!\n* Consolidate `git-link-*-alist`s\n* `git-link-grep`\n","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fgit-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshaw%2Fgit-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fgit-link/lists"}