Subham Burnwal
Subham Burnwal

Reputation: 369

How to list all my Github repositories, public and private in the terminal with git or in Vim with Fugitive?

I have a few repositories on my Github account and I am trying to pipe a list of names of all these repos (private and public) to some scripts for automating a few tasks.

What I did-

Any ideas?

Upvotes: 2

Views: 1554

Answers (2)

TamaMcGlinn
TamaMcGlinn

Reputation: 3238

This is now possible using github's cli. For instance, on Ubuntu this works:

sudo snap install gh
gh auth login
$ gh repo list tpope

Showing 30 of 84 repositories in @tpope

tpope/vim-dadbod              dadbod.vim: Modern database interface for Vim                                           public        1d
tpope/vim-fugitive            fugitive.vim: A Git wrapper so awesome, it should be illegal                            public        2d
tpope/vim-unimpaired          unimpaired.vim: Pairs of handy bracket mappings                                         public        2d
tpope/vim-commentary          commentary.vim: comment stuff out                                                       public        8d
(...)

Integrating this into vim-fugitive would best be a separate question.

Upvotes: 1

bk2204
bk2204

Reputation: 76429

The only way to find this information is via the GitHub API (e.g., using this API call), which will require an HTTP client and some JSON parsing. Usually, this will be done via curl and jq, but you can also do it with a language such as Ruby.

This information isn't exposed by Git because Git doesn't expose the concept of having a single account on a server with multiple, discoverable repositories. Many sites hosting repositories don't have this concept, either. Fugitive is just a wrapper around Git, so it also doesn't have this concept, although there are extensions to support it working with GitHub that may provide this functionality.

Upvotes: 0

Related Questions