Created
January 25, 2026 18:01
-
-
Save disouzam/fe3416fcc7734900f1b697c5091c81f5 to your computer and use it in GitHub Desktop.
Get commit remote URL via command line using Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function get_commit_url() { | |
| echo "$(git config --get remote.origin.url)" | \ | |
| sed -e 's/git@/https:\/\//' -e 's/\.git$//' \ | |
| | awk -v sha="$(git rev-parse $1)" '{print $0"/commit/"sha}' | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use it
When in a git repo in your computer, execute the commands below:
get_commit_url {commit-hash}Example:
Consider this commit:
https://github.com/gvwilson/sim/commit/0f3ca1f35b34d374d727b558ee4633b35bd6a5dfget_commit_url 0f3ca1f35b34d374d727b558ee4633b35bd6a5df # https://github.com/gvwilson/sim/commit/0f3ca1f35b34d374d727b558ee4633b35bd6a5df