This guide will provide the explanation about:
- How to Get the Git Local Repository’s Name?
- How to Get the Git Remote Repository’s Name?
- How to Fetch and Show the “origin” Remote URL?
How to Get the Git Local Repository’s Name?
Git developers can get the local repository name and the base directory name. For this corresponding purpose, the “git rev-parse” command can be used:
Here, the “–show-toplevel” option is used for displaying the root directory of Git, which can be seen in the output:
How to Get the Git Remote Repository’s Name?
If developers want to get the Git remote repository name along with the path, the “git config” command can be utilized as follows:
In the above-stated command:
- “–get” option is used to fetch the required value.
- “origin” is our remote URL name.
According to the below-given output, the “origin” contains the “demo5” remote repository:
How to Fetch and Show the “origin” Remote URL?
To fetch the value of the remote URL, execute the given command:
Here:
- “remote show” is used to show the required value.
- “origin” is the name of our remote URL.
- “-n” flag indicates the number.
- “grep” command to find the Git local branches and checkout branches.
- “Fetch URL:” will display the fetched remote URL.
It can be observed from the output that the value of the remote URL is displayed, where the remote repository name is “demo5”:
That’s all! We have explained the process of getting the local root directory and remote repository name along with its path.
Conclusion
Git developers can get the name of Git’s local root repository name. The “git rev-parse –show-toplevel” command can be utilized for this corresponding purpose. To get the GitHub repository’s full path, execute the “git config –get remote.<remote-name>.url” command. The “git remote show <remote-name> -n | grep “Fetch URL:”” command can be used. This guide explained the different commands to get the local root directory and remote repository name along with its path.