When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands?
# I did check out bar
Unfortunately, it seems that Git has no such command built in. But you can easily add it yourself with Git aliases and some shell magic.
As pointed out by this answer, you can use git rev-parse --show-toplevel to show the root of your current Git folder.
If you want to use this regularly, it's probably more convenient to define it as an alias. For this, used git config alias.root '!echo "$(git rev-parse --show-toplevel)"'. After this, you can use git root to see the root folder of the repository you're currently in.
If you want to use another subcommand name than root, simply replace the second part of alias.root in the above command with whatever you want.
For details on aliases in Git, see also the git config man page.