As part of a project I'm working on, I've had to clone a lot of repos. Like, several hundred repos. Many of them work together, in small and large projects, some are shared resources for all, and still others are one-offs. It's easy to forget as I'm navigating between directories which repo I'm currently messing with. Which branch am I on? Is it this repo? That repo? A subrepo? A bleepo? Sweepo?
My first thought was to run
git status but that only shows the branch and the status of any changed files - not the repo I'm in, or the organization it's associated with. The command I needed was git remote show origin, which shows the URL along with some other info.
> git remote show origin * remote origin Fetch URL: firstname.lastname@example.org:grantwinney/BlogCodeSamples.git Push URL: email@example.com:grantwinney/BlogCodeSamples.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (local out of date)
> git config --get remote.origin.url firstname.lastname@example.org:grantwinney/BlogCodeSamples.git
And to get the name of the repo only, run the above output through
> basename `git config --get remote.origin.url` BlogCodeSamples
I'm running in Windows, so I used this fine answer to create a
c:\Aliases\whereami.bat file with the following contents in it:
@echo off git config --get remote.origin.url git branch
I added it to my path, and now when I'm in a repo I can pound out "whereami" to get my repo name. :)
C:\Users\grant\BlogCodeSamples> whereami email@example.com:grantwinney/BlogCodeSamples.git * master
And since you made it this far... 🚀🛸