How to Show Information About Remote Repository in Git
This tutorial is about showing information about remote repositories in Git. We use Git, a version control system, to keep track of the changes done to files in our project directory with a Git repository.
Typically, a local repository is tracked with a remote repository in Git. We can view the information about the remote repository using the git remote
command.
We will illustrate this with an example.
Show Information About Remote Repository in Git
We use Git in a collaborative development environment to keep track of the changes done to files in our project directory.
We track the changes using a Git repository, building history over time. Thus, a Git repository is a virtual storage of our project.
It allows us to save code versions, which we can access when needed. Typically, a local Git repository is tracked with a remote Git repository.
We use the git clone
command to clone a repository. The git clone
command creates a remote connection named origin
pointing back to the cloned remote repository.
Thus, the origin
provides an easy way to pull upstream changes or push local commits.
We can view the information about the remote repository using the git remote
command with the show
option. The git remote
command manages a set of repositories that we are tracking.
Thus, suppose we have a project named MyProject
that is tracked with a remote repository in GitHub, a popular code hosting platform for version control and collaboration, with the same name.
We can view information about the remote using the git remote
command with the show
option as follows.
$ cd MyProject
$ git remote show origin
* remote origin
Fetch URL: git@github.com:johndoe/MyProject.git
Push URL: git@github.com:johndoe/MyProject.git
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (local out of date)
Thus, we can see that the git remote
command and the show
option provide a detailed output of the configuration of the remote repository.
The output shows the list of branches associated with the repository and the endpoints attached for fetching and pushing.
Thus, in our case, the master
branch of the remote repository is shown as tracked. The fetch and push URLs are shown as the GitHub URLs of the remote repository.
It also shows whether the local branch is out of date, as shown in the output above.
Sometimes, we only want to view the remote URL and, when we are not connected to the network, we can reach the remote repository.
In such a case, we can view the remote URL as follows.
$ git config --get remote.origin.url
git@github.com:johndoe/MyProject.git
Thus, we have learned about showing information about remote repositories in Git.
For more information, please visit these links.
Related Article - Git Remote
- How to Add SSH in Git Remote
- How to Remove Upstream Repository in Git
- How to Create a Remote Repository From a Local Repository in Git
- How to Synchronize a Local Repository With a Remote Repository in Git
- How to Update a Repository by Setting Up a Remote
- How to Push From an Existing Remote Repository to a Different Remote Repository in Git