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
Author
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/0f3ca1f35b34d374d727b558ee4633b35bd6a5df
get_commit_url 0f3ca1f35b34d374d727b558ee4633b35bd6a5df
# https://github.com/gvwilson/sim/commit/0f3ca1f35b34d374d727b558ee4633b35bd6a5df
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got the code for this Gist from someone over StackOverflow. Unfortunately, I didn't keep track of the source.