When you do your first clone using the syntax
git clone username@server:gitRepo.git
Is it possible using your local repository to find the name
Edited for clarity:
This will work to to get the value if the remote.origin.url is in the form protocol://auth_info@git_host:port/project/repo.git. If you find it doesn't work, adjust the -f5 option that is part of the first cut command.
For the example remote.origin.url of protocol://auth_info@git_host:port/project/repo.git the output created by the cut command would contain the following:
-f1: protocol: -f2: (blank) -f3: auth_info@git_host:port -f4: project -f5: repo.git
If you are having problems, look at the output of the git config --get remote.origin.url
command to see which field contains the original repository. If the remote.origin.url does not contain the .git string then omit the pipe to the second cut command.
#!/usr/bin/env bash
repoSlug="$(git config --get remote.origin.url | cut -d/ -f5 | cut -d. -f1)"
echo ${repoSlug}