GH cli - how to get current repo?

Viewed 431

Use GitHub cli (gh), how do I get a current repo name?

I can get a listing of the repos I have but how do I get the current repo?

1 Answers

To get the name of the repo in the curernt working directory, run

gh repo view --json name -q ".name"

This extracts the name of the repo from the command that lists information about the repo in the current directory, and extracts the actual name from the JSON output. For instance, if you were in the working directory for the repo with a URL of http://github.com/rust-lang/rust, the output would be rust.

Related