Extract repository name from GitHub url in bash

Solution 1:

$ url=git://github.com/some-user/my-repo.git
$ basename=$(basename $url)
$ echo $basename
my-repo.git
$ filename=${basename%.*}
$ echo $filename
my-repo
$ extension=${basename##*.}
$ echo $extension
git

Solution 2:

I'd go with basename $URL .git.