Sentry Answers>Git>

Determine the origin of a cloned Git repository

Determine the origin of a cloned Git repository

David Y.

The ProblemJump To Solution

How can I find out which URL a local Git repository was originally cloned from?

The Solution

By default, a cloned Git repository has a remote named origin, which refers to the remote repository from which it was cloned. To obtain the URL of this remote, we can use the following command:

Click to Copy
git ls-remote --get-url origin

To obtain more information about the remote repository, such as its branches, we can run the following command:

Click to Copy
git remote show origin

Note that this second command requires the remote repository to be reachable over the network but the first command does not.

If our remote is not called origin, we can retrieve the URLs of all remotes using the following command:

Click to Copy
git remote -v

As remotes can be added, removed, or modified at any time, there is a chance that the remotes in your local repository may not include the remote from which it was originally cloned.

  • ResourcesWhat is Distributed Tracing
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty Treats for Web Developers brought to you by Sentry. Web development tips and tricks hosted by Wes Bos and Scott Tolinski

    Listen to Syntax

Loved by over 4 million developers and more than 90,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.