git remote get-url <remote>
This command is useful to quickly check where a remote like origin is pointing (e.g. GitHub or another server) so you can confirm or debug your repository’s remote configuration.
This command runs in your local Git repo and asks Git to print the URL configured for the remote name you pass in <remote>, where <remote> is usually something like origin or upstream; the <remote> value is a positional argument that tells Git which remote’s fetch URL to display, and by default it shows the fetch URL, but you can add --push to show the push URL instead, or --all to show both fetch and push URLs. The flag --push is just a more specific way to ask for the push URL instead of the fetch URL, and --all is another way to ask Git to output both kinds of URLs for that remote in one go.
This is especially helpful when you’ve changed hosting providers, cloned from someone else’s repo, or are troubleshooting why pushes/pulls go to the wrong place, because it lets you confirm the exact protocol (https, ssh, etc.) and target path the remote is using.
You can use related variants like git remote -v to list all remotes with their fetch and push URLs, or git remote set-url <remote> <new-url> to change the URL after you’ve inspected it with this command, and git remote show <remote> for a more detailed view of the remote’s configuration.
Examples:
git remote get-url origingit remote get-url --push origingit remote get-url --all origin