ingydotnet / git-hub

Do GitHub operations from the `git` command
MIT License
794 stars 62 forks source link

=pod

=for comment DO NOT EDIT. This Pod was generated by Swim v0.1.48. See http://github.com/ingydotnet/swim-pm#readme

=encoding utf8

=head1 Name

git-hub - The Git command for GitHub

=for html git-hub

=head1 Synopsis

Here are just a few of the things you can do on GitHub with a simple command:

git hub                             # Show the `git hub` cheat sheet
git hub help                        # Show this awesome documentation
git hub setup                       # Config dialog. Do this first!

git hub user <user>                 # Get info about a user
git hub repos <owner>               # List recent repositories
git hub repo-new <repo>             # Create a new repository
git hub fork <owner>/<repo>         # Fork a repository
git hub clone <owner>/<repo>        # Clone a GitHub repository
                                    # Set/Change your repo description
git hub repo-edit <repo> description 'Just another GitHub repo'
git hub repo-delete <owner>/<repo>  # Delete a repository
git hub followers <user>            # List a user's followers
git hub star ingydotnet/git-hub     # Star this repository
git hub watch ingydotnet/git-hub    # Watch this repository
git hub follow ingydotnet           # Follow this author
git hub trust ingydotnet            # Add collaborators to repo
                                    # Stalk all your followers
git hub followers -ra | git hub user -
git hub gists <user>                # List gists for a user

=head1 Description

The B subcommand for git, allows you to perform many of the operations made available by GitHub's v3 REST API, from the C commandline command.

You can fork, create, delete and modify repositories. You can get information about users, repositories and issues. You can B, B and B things, and find out who else is doing the same. The API is quite extensive. With this command you can do many of your day to day GitHub actions without needing a web browser.

You can also chain commands together using the output of one as the input of another. For example you could use this technique to clone all the repos of a GitHub user or organization, with one command. See PIPE AND EACH below.

=head1 Installation

There are currently 3 ways to install C. For all of them you need to get the source code from GitHub:

git clone https://github.com/ingydotnet/git-hub /path/to/git-hub

The first installation method is preferred: C the C<.rc> file. Just add a line like this one to your shell startup script:

source /path/to/git-hub/.rc

That will modify your C and C, and also enable command completion.

The second method is to do these things by hand. This might afford you more control of your shell environment. Simply add the C and C directories to your C and C:

export PATH="/path/to/git-hub/lib:$PATH"
export MANPATH="/path/to/git-hub/man:$MANPATH"

See below for info on how to turn on Command Completion.

The third method is a standard system install, which puts C next to your other git commands, do this instead:

make install        # Possibly with 'sudo'

To install to a place of your choice:

DESTDIR=/place/of/your/choice make install

The C method does not account for upgrading and command completion yet.

See "Upgrading" and "Command Completion" below.

=head1 Command Options

Commandline options start with a dash and can appear in any order in the command. Long form commands that require an argument can use '=' or not:

--count=5
--count 5

=over

=item C<< -c >>, C<< count= >>

This option is for commands that return a list of things. Specify the number of items you want the command to return. Each list command has a reasonable default value.

=item C<-a>, C<--all>

Show all elements for list commands. Also applies to a few other commands as documented.

=item C<-r>, C<--raw>

For commands that produce lists, just list the raw data. For commands that produce reports, show the raw storage keys, rather than the human friendly ones. You will need the raw keys to edit/change values.

=item C<-j>, C<--json>

For some commands, you can get the raw data in JSON.

=item C<->

This option, just a single '-', is small but very powerful. It means to read the next line from stdin, and put the content into the command at that point. See PIPE and EACH below.

=item C<=>

Like the '-' command above, but reads each B from stdin.

=item C<-h>

Show the brief command usage.

=item C<--help>

Show the full documentation.

=item C<-q>, C<--quiet>

Show minimal output.

=item C<-v>, C<--verbose>

Show detailed output. Notably, show the raw command that is used for the GitHub API calls.

=item C<< --token= >>

Set or override the api-token required by the command. This value can also come from the C environment variable. Usually this value comes from your C<~/.git-hub/config> file.

=item C<-d> C<--dryrun>

Don't actually make the API call. This option turns on verbose mode.

=item C<-T>

Show the API token in the verbose output. Hidden by default. This option turns on verbose mode.

=item C<-A>, C<--use-auth>

Use authentication whether or not it is needed for a certain command. This is useful if you have exceeded your hourly GitHub API rate limit, which is 60 calls unauthenticated, and 5000 calls authenticated.

=item C<-C> C<--no-cache>

There are currently known bugs in GitHub's cache headers. If the content seems stale, use this option.

=back

=head2 Debug Options

There are a number of debug options that will give you lots of extra information (albeit in a less pretty format).

=over

=item C<-O>

Show the API reponse output. Always in JSON format. JSON is pretty-printed.

=item C<-H>

Show the API response headers.

=item C<-J>

Show the API response JSON, in decoded form.

=item C<-R>

Repeat the last command, using the previous API server response. Useful for development and debugging. (Beware, only caches the most recent API call, so not really good for commands that make multiple calls).

=item C<-x>

Turn on Bash C<-x> debugging. This will show every bash command executed in the program. This is extremely useful to track down nasty bugs.

=back

=head1 Arguments

The C command gets its input values from these sources (in this order):

=over

=item * Commandline B (see specific command, below).

=item * Environment variables of the form C.

=item * The C<./.git/config> file. (The repo you are issuing commands from)

=item * The C<~/.git-hub/config> file.

=back

Most of the commands described below have arguments. This section defines each of the argument types. Note that argument values that are strings containing whitespace need to be quoted.

Argument variable names are always indicated by angle brackets, like: C<< >>. Arguments listed in square brackets are optional and arguments followed by C<...> indicate that more than one is allowed.

=over

=item C<< >>

A GitHub user name. Sometimes an organization name can be used instead. If this argument is optional, it defaults to the GitHub owner of the repo you are currently in. If you are not in a GitHub repo, it defaults to your login. B: C environment variable.

=item C<< >>

A GitHub user or organization that owns the repository being specified. This value defaults much like the C<< >> argument (above). B: C environment variable.

=item C<< >>

A GitHub organization name. B: C environment variable.

=item C<< >>

A GitHub repository name. If this argument is optional, it defaults to the GitHub repo name of the repo you are currently in. B: C environment variable.

=item C<< / >>

Many commands need both an owner and repo separated by a slash. If the owner is you (your GitHub login) you can omit it (but you still need the leading slash). Like C, instead of C<me/myrepo>. If this argument is optional, it defaults the the owner and repo of the GitHub repo you are in.

=item C<< >>

Two strings separated by whitespace. Values with embedded whitespace should be quoted. The documentation of each command that needs these pairs, will list the valid keys.

=item C<< >>

The integer number B of a token (not the 40 hex-character value).

=item C<< >>

One of the GitHub scopes that you can apply to a token. The C command will tell you all of these, and what they mean.

=back

=head1 Commands

These are the commands you can use to perform most of your daily GitHub interactions from the command line. They are installed by default.

=over

=item C

Show this manpage.

=item C

Print version info for C.

=item C

Show detailed version and environment info about your C installation. This can be useful for figuring out things about how C is operating in a given situation. Also good for reporting bugs / issues in C.

=item C

Before you can use the commands described below, you need to perform some setup/configuration steps.

This "wizard" style dialog, will walk you through the configuration process quickly and painlessly, with lots of explanation. You should run this command right away. You can also re-run it, and it will allow you to change your config, while defaulting to your existing settings.

If you would rather do the steps by hand, see L<#Configuration-Commands> below.

=item C

Upgrade the C installation to the latest version. Note: you need to be running 'git-hub' from the source repo, and be on the main branch for this to work.

=item C<< user [] >>

Show basic information about a specific user. User defaults to the owner of the current repo, or your login if you are not inside a repo directory. The C<--raw> and C<--json> options show the data in different formats than normal output.

=item C<< user-get >>

Get a specific data value for a particular user.

=item C<< user-edit ... >>

Set specific fields of your user info to new values. You list the parameters as key/value pairs.

You can edit the following user keys: C, C, C, C, C, C.

=item C<< orgs [] >>

List the organizations that a user is a member of.

=item C<< org >>

Show basic information about a GitHub organization. The C<--raw> and C<--json> options show the data in different formats than normal output.

=item C<< org-repos >>

Show all the repos for an organization, both public and private.

=item C<< org-members >>

List members of an organization.

=item C<< org-get >>

Get a specific data value for a particular organization.

=item C<< org-edit ... >>

Set specific meta-data fields of an organization to new values. You list the parameters as key/value pairs.

You can edit the following organization keys: C, C, C, C, C, C.

=item C<< teams >>

List the teams in an organization.

=item C<< team >>

Get information about a team.

=item C<< team-members >>

List members of a team.

=item C<< team-repos >>

List repos of a team.

=item C<< team-repo-add >>

Add repo to a team. Repo name must not include org name.

=item C<< team-new >>

Add a new team (name) to an organization. The 'perm' arg must be pull, push or admin.

=item C<< team-delete >>

Delete a team.

=item C<< members | >>

List the members of an organization or team. If numeric argument, show team members, else organization members.

=item C<< member-get >>

Show whether a user is a member of a specified team.

=item C<< member-add >>

Add a user to a team.

=item C<< member-remove >>

Remove a user from a team.

=item C<< followers [] >>

List the people who are followers of a user.

=item C<< follows [] >>

Check if C<< >> follows C<< >>. The default target user is you.

=item C<< following [] >>

List the people that a user is following.

=item C<< follow ... >>

Follow one or more users.

=item C<< unfollow ... >>

Stop following one or more users.

=item C<< clone ([/] [])... >>

Clone a GitHub repo. Always uses C<--recursive> so you get submodules too. You can specifiy a list of repos. If you specify a directory for a repo, it should be an absolute path name or else begin with '.I<' or '..>' so that it can be distinguished from another repo name.

=item C<< repos [] >>

List the repos for a user or organization. List is returned in order of recent activity.

=item C<< repo [] >>

Show basic information about a specific repository. The C<--raw> and C<--json> options show the data in different formats than normal output.

=item C<< repo-get / >>

Get a specific data value for a particular repository.

=item C<< repo-edit [/] ... >>

Set specific meta-data fields of a repository to new values. You list the parameters as key/value pairs.

You can edit the following repo keys: C, C.

=item C<< repo-new [/] >>

Create a new GitHub repository.

=item C<< repo-init [] >>

This command is useful for setting up new repos. Just mkdir a new dir, cd into it and issue the command. It will 'git init', make the GitHub repo and add it as the origin remote. It will only do the things that have not yet been done.

=item C<< repo-delete / >>

Delete a GitHub repository.

=item C<< forks [/] >>

List the forks of a repository.

=item C<< fork / [--org=] [--remote=] >>

Fork a repository to your account or to an organization. Optionally, you can specify the name of a remote to add, pointing to your fork.

=item C<< stars [/] >>

Show what users have starred a repository.

=item C<< star [/] >>

Add your B to a repository.

=item C<< unstar [/] >>

Remove your B from a repository.

=item C<< starred [] >>

List repositories that a user has starred.

=item C<< watch [/] >>

Start watching a repo.

=item C<< unwatch [/] >>

Stop watching a repo.

=item C<< watching [] >>

Show which repos a user is watching.

=item C<< watchers [/] >>

Show the users who are watching a repo.

=item C<< collabs [/] >>

List current collaborators for a repository.

=item C<< trust [/] ... >>

Add one or more collaborators to a repository.

=item C<< untrust [/] ... >>

Remove one or more collaborators from a repository.

=item C<< issues [/] [--all] >>

List the open issues for a repo. Use the C<--all> flag to see both open and closed issues.

=item C<< issue [/] >>

Show info (including any comments) for a specific issue. If no issue number is given, this command will call C instead.

=item C<< issue-new [/] >>

Create a new issue for a repository.

=item C<< issue-edit [/] >>

Add a comment. Change values of 'title', 'state', 'assignee' and 'milestone'. Changing state to 'closed' will close the issue.

=item C<< comment [/] >>

Add a comment to an issue. You can also use C to just add a comment.

=item C<< issue-close [/] >>

Close an issue. You can also use C to close an issue.

=item C<< issue-resolve [/] >>

Add a comment to an issue and then close it.

=item C<< pr-list [/] >>

List the pull requests for a repo.

=item C<< pr-new [] [] >>

Create a new pull request for a repository based on the current branch. If an issue ID number is given, this command will attach the pull request to the issue instead of creating a new one.

If the default remote is a fork, the pull request will target the default branch of the parent repository. Otherwise the pull request will target the default branch of the default remote itself. Use C<--remote>, C<--branch>, C<--parent>, and C<--base> options to change the default source remote, source branch, target remote and target branch (respectively).

This command will open an editor like C does. To avoid that you can pipe text into the command.

=item C<< pr-diff [/] >>

Show the diff for a pull request.

=item C<< pr-fetch [/] >>

Fetches a pull request to a local C<review/$number> branch

=item C<< pr-merge [/] >>

Merge and close a pull request.

It supports the following options:

=over

=item * C<--sha>

=item * C<--merge-method>

=item * C<--commit-title>

=item * C<--commit-message>

=back

=item C<< pr-queue [] [--all] >>

Show a user's Pull Request queue, for all repos. Shows the open PRs for any repo that has them. The C<--all> option says to show closed as well as open PRs. Results are sorted by date of creation.

=item C<< pr-created [] [--all] >>

Show a list of Pull Requests the user created, for all repos. Shows the open PRs for any repo that has them. The C<--all> option says to show closed as well as open PRs. Results are sorted by date of creation.

=item C<< pr-involves [] [--all] >>

Show a list of Pull Requests the user is involved in. ie Pull Requests that were created by, assigned to, mention, or were commented on by that user. Shows the open PRs for any repo that has them. The C<--all> option says to show closed as well as open PRs. Results are sorted by date of creation.

=item C<notify-list [--all]>

List your recent I user notifications. To list your I notifications as well, use the C<--all> option.

=item C<< keys [] >>

List public SSH keys for a user.

=item C<< keys-add <key> >></p> <p>Add a public ssh key for your user.</p> <p>=item C<cache-clear></p> <p>Clear your API response cache.</p> <p>=item C<< open [<owner>/<repo>] [<file-path>] >></p> <p>Open a browser window to a repo or a file in a repo.</p> <p>=item C<< url [<owner>/<repo>] [<file-path> [<line-number>]] >></p> <p>Print the URL of a repo or a file in a repo.</p> <p>=item C<git-hub-travis></p> <p>Enable and/or disable travis-ci testing from the command line.</p> <p>=item C<< gists [<user>] >></p> <p>List gists for a user.</p> <p>=item C<< gist <gist-id> >></p> <p>Show info about gist.</p> <p>=item C<< gist-get <gist-id> <data-key> >></p> <p>Get a specific data value for a particular gist.</p> <p>=item C<< gist-edit <gist-id> <key-value-pair...> >></p> <p>Set specific meta-data fields of a gist to new values. You list the parameters as key/value pairs.</p> <p>=item C<< gist-star <gist-id> >></p> <p>Add your B<star> to a gist.</p> <p>=item C<< gist-unstar <gist-id> >></p> <p>Remove your B<star> from a gist.</p> <p>=item C<< gist-delete <gist-id> >></p> <p>Delete a gist.</p> <p>=item C<< gist-clone <gist-id> [<directory>] >></p> <p>Clone a gist.</p> <p>=item C<< gist-fork <gist-id> >></p> <p>Fork a gist.</p> <p>=item C<< gist-new (public|secret) <description> <files...> >></p> <p>Create a gist from existing files</p> <p>=item C<< gist-init (public|secret) <description> >></p> <p>Create an (almost) empty gist and clone it</p> <p>This will create a gist with a file '.gitignore'</p> <p>=item C<< search-repo <query> >></p> <p>Search for repositories.</p> <p>By default it searches in the repository name, but you can change that: C<search-repo "libyaml in:description">. For more information, see the search documentation at L<a rel="noreferrer nofollow" target="_blank" href="https://developer.github.com/v3/search/#search-repositories">https://developer.github.com/v3/search/#search-repositories</a></p> <p>=item C<< search-user <query> >></p> <p>Search for users.</p> <p>By default it searches in the login field, but you can change that: C<search-user "wall in:fullname">. For more information, see the search documentation at L<a rel="noreferrer nofollow" target="_blank" href="https://developer.github.com/v3/search/#search-users">https://developer.github.com/v3/search/#search-users</a></p> <p>=item C<< search-issues <query> >></p> <p>Search for issues and pull requests. For more information, see the search documentation at L<a rel="noreferrer nofollow" target="_blank" href="https://developer.github.com/v3/search/#search-users">https://developer.github.com/v3/search/#search-users</a></p> <p>=back</p> <p>=head2 Plugin Commands</p> <p>You get tons of useful commands by default, and they are all listed and documented in the next section below. But C<git-hub> also supports third party plugin commands.</p> <p>This section is about the "plugin" commands that currently come with C<git-hub>.</p> <p>=over</p> <p>=item C<< irc-enable <room> [<server>] >></p> <p>This command must be run inside a cloned repo. It enables GitHub activities for a repo to be reported to an IRC channel.</p> <p>=item C<irc-enable></p> <p>This command must be run inside a cloned repo. It disables the GitHub IRC webhook for a repo.</p> <p>=item C<irc-url></p> <p>Show the GitHub URL for setting webhooks on the current repo.</p> <p>=back</p> <p>=head2 Configuration Commands</p> <p>These commands are for editing your C<git-hub> config file and managing your GitHub authentication tokens.</p> <p>=over</p> <p>=item C<< config [<config-key> [<config-value>]] >></p> <p>With no args, this command will print the contents of C<~/.git-hub/config>. With With one argument (a key), print the current value of the config key. With two arguments (key value), set the value of the config key. 4 keys are currently supported: C<login>, C<api-token>, C<use-auth>, and C<json-lib>.</p> <p>=item C<< config-unset <config-key> >></p> <p>Unset a config key. Removes the key from the C<~/.git-hub/config> file.</p> <p>=item C<config-list></p> <p>Will list your current configuration like C<git config --list></p> <p>=item C<config-keys></p> <p>Output all possible configuration keys</p> <p>=item C<tokens></p> <p>List all the API tokens for your GitHub account. Use the C<--raw> option to print the token IDs and descriptions, but not the actual token values.</p> <p>=item C<< token-new [<description-string>] >></p> <p>Create a new API token for your GitHub login id. Note: Creating a new token will not automatically add it to your C<~/.git-hub/config> file; you need to do that yourself with the C<< git hub config api-token <token-value> >> command. Use the C<--raw> option to just print the new token id.</p> <p>=item C<< token-get <api-token-id> <data-key> >></p> <p>Get a specific data value for a particular token.</p> <p>=item C<< token-delete <api-token-id> >></p> <p>Delete one of your API tokens for your GitHub login id. Note: You need to delete tokens by B<id> (listed by the C<tokens> command), not by token value.</p> <p>=item C<< scopes <api-token-id> >></p> <p>List the scopes assigned to your API token, and also list all the possible scope values that you can assign. Use the C<--raw> option to just list the scopes.</p> <p>=item C<< scope-add <api-token-id> <scope-name>... >></p> <p>Add one or more scopes to your API token. You can use the C<--all> option to add all possible scopes at once.</p> <p>=item C<< scope-remove <api-token-id> <scope-name>... >></p> <p>Remove one or more scopes from your API token. You can use the C<--all> option to remove all possible scopes at once.</p> <p>=back</p> <p>=head1 Upgrading git-hub</p> <p>If you used the C<PATH> method of installation, just run this to upgrade C<git-hub>:</p> <pre><code>git hub upgrade</code></pre> <p>Or (same thing):</p> <pre><code>cd /path/to/git-hub git pull</code></pre> <p>If you used C<make install> method, then run this again (after C<git pull>):</p> <pre><code>make install # Possibly with 'sudo'</code></pre> <p>=head1 Command Completion</p> <p>The C<git hub> command supports C<< <TAB> >>-based command completion. If you don't use the C<.rc> script (see Installation, above), you'll need to enable this manually to use it.</p> <p>Completion is supported for subcommands, options and config keys.</p> <pre><code> git hub <TAB> git hub pr-list --<TAB> git hub config <TAB> git hub help <TAB></code></pre> <p>Additionally, user/repo names can be completed, but note that there might be some cases where this will not offer all possible names.</p> <p>The reason is the search is restricted to 100 items, and a search cannot be anchored to the start of a string, so an API call might return 100 results, but you will only see those starting with the prefix you typed.</p> <p>=head2 Completing repository names</p> <pre><code> git hub repo <TAB> shortcut for your-login/<TAB> git hub repo @<TAB> shortcut for your-login/<TAB> git hub repo foo<TAB> shortcut for your-login/foo<TAB> git hub repo user/<TAB> complete repos of 'user' git hub repo user/foo<TAB> complete repos of 'user' starting with foo</code></pre> <p>=head2 Completing user names as part of the full repository name</p> <p>For completing usernames, you have to type a C<@> and at least two characters.</p> <p>C<< git hub repo @in<TAB> >></p> <p>The C<@> will automatically go away if there is only one matching user, or if you add a C</> after it.</p> <pre><code> git hub repo @ingyd<TAB> -> git hub repo ingydotnet/ git hub repo @ingydotnet/<TAB> -> git hub repo ingydotnet/</code></pre> <p>=head2 Completing user names for commands like follow, user, trust</p> <p>This is not supported yet.</p> <p>=head2 Enabling completion</p> <p>=head3 In Bash</p> <p>If your Bash setup does not already provide command completion for Git, you'll need to enable that first:</p> <pre><code>source <Git completion script></code></pre> <p>On your system, the Git completion script might be found at any of the following locations (or somewhere else that we don't know about):</p> <p>=over</p> <p>=item * C</etc/bash_completion.d/git></p> <p>=item * C</usr/share/bash-completion/git></p> <p>=item * C</usr/share/bash-completion/completions/git></p> <p>=item * C</opt/local/share/bash-completion/completions/git></p> <p>=item * C</usr/local/etc/bash_completion.d/git></p> <p>=item * C</usr/local/opt/git/share/git-core/contrib/completion></p> <p>=item * C<~/.homebrew/etc/bash_completion.d/git></p> <p>=back</p> <p>In case you can't find any of these, this repository contains a copy of the Git completion script:</p> <pre><code>source /path/to/git-hub/share/git-completion.bash</code></pre> <p>Once Git completion is enabled (whether you needed to do that manually or not), you can turn on C<git-hub> completion with a command like this:</p> <pre><code>source /path/to/git-hub/share/completion.bash</code></pre> <p>=head3 In zsh</p> <p>In the Z shell (zsh), you can manually enable C<git-hub> completion by adding the following line to your C<~/.zshrc>, B<before> the C<compinit> function is called:</p> <pre><code>fpath=('/path/to/git-hub/share/zsh-completion' $fpath)</code></pre> <p>You might want to enable caching (the cache is invalidated after 20 minutes):</p> <pre><code> zstyle ':completion:*' use-cache on</code></pre> <p>=head1 Plugins</p> <p>The C<git-hub> command supports plugins. All you need to do to install a plugin, is to clone the plugin repo into the C<plugin/> subdirectory of the C<git-hub> repository. There are example plugins already installed. If you do a system-style install, then just C<make install> the plugins too.</p> <p>=head1 Faster</p> <p>The C<git-hub> command is written in pure Bash, including a complete JSON parser written in Bash. Unfortunately, this parser is a bit slow. It is B<really> slow for large API payloads.</p> <p>To make the C<git-hub> command perform much faster, just run this command:</p> <pre><code>git hub config json-lib json-perl.bash</code></pre> <p>That will enable a Perl replacement, which requires Perl (of course) and the JSON.pm Perl module. If the JSON::XS Perl module is also installed, it will be even faster.</p> <p>=head1 Pipe and Each</p> <p>You can pipe the output of one C<git hub> into another and multiply your power. The command being piped into should use the EACH option which is a single dash ('-'). It will cause the command to be run once for each line of input, inserting the line into the command, in place of the '-'. If you use a '=' it will do the same thing except for each "word" of input.</p> <p>This command:</p> <pre><code>git hub followers --raw</code></pre> <p>will list lines containing only user ids. You can pipe it into commands needing a user id, like:</p> <pre><code>git hub followers --raw | git hub user - --json</code></pre> <p>Thus printing the JSON user info for each follower. Same as:</p> <pre><code>for _ in `git hub followers --raw`; do git hub user $_ --json done</code></pre> <p>For '=' you can do things like:</p> <pre><code>echo alice bob chelsea | git hub trust =</code></pre> <p>to trust a list of users in one go.</p> <p>=head1 Token Authentication and Scopes</p> <p>Many endpoints of the GitHub v3 API require a Personal API Access Token. You can list your current tokens with this command:</p> <pre><code>git hub tokens</code></pre> <p>If you don't have any tokens or want a new one for the C<git-hub> command, run these commands (the C<git hub setup> command automates this):</p> <pre><code>git hub token-new "my git-hub command token" git hub scope-add <token-id> user repo git hub scopes <token-id> git hub config api-token <token-value></code></pre> <p>You can also see all your tokens on the web at L<thispage|<a rel="noreferrer nofollow" target="_blank" href="https://github.com/settings/applications">https://github.com/settings/applications</a>>.</p> <p>You can specify your API token to C<git hub> on the commandline with C<--token=...> or in the C<GIT_HUB_API_TOKEN> environment variable, but the easiest thing to do is just set it in the git-hub config.</p> <p>Certain token B<scopes> are required for various GitHub API operations. Make sure your token has the scopes turned on for the things you want to do. See the C<scopes>, C<scope-add> and C<scope-remove> C<git hub> subcommands.</p> <p>NOTE: All the C<git hub> commands dealing with tokens and scopes require you to enter your GitHub password. If you need to issue a bunch of these commands and you don't want to retype your password each time, you can put your password in the C<GIT_HUB_PASSWORD> environment variable.</p> <p>=head1 Rate Limits</p> <p>GitHub limits unauthenticated API calls to 60 per hour, and authenticated API calls to 5000 per hour. For this reason you may wish to use authentication even for calls that don't need it. You can use the C<-A/--use-auth> option to make sure a command uses authentication. You can also set the config file to always use authentication, with this command:</p> <pre><code>git hub config use-auth true</code></pre> <p>Another option is to set the GIT_HUB_USE_AUTH environment variable:</p> <pre><code>export GIT_HUB_USE_AUTH=true</code></pre> <p>=head1 ETAG Caching</p> <p>GitHub provides ETag headers in the API responses, and C<git-hub> uses them to cache responses, by default. When you use this feature, your rate-limit usage is not affected for cached responses.</p> <p>GitHub has had caching bugs in their API in the past. If you suspect the cache is stale, you may want to try these options:</p> <p>=over</p> <p>=item * Use the C<-C> (C<--no-cache>) flag on a request to bypass the cache.</p> <p>=item * Set C<GIT_HUB_NO_CACHE=true> to bypass the cache.</p> <p>=item * Run C<git hub config no-cache true> to never use the cache.</p> <p>=item * Run C<git hub cache-clear> to erase all the cached values.</p> <p>=back</p> <p>=head1 Colors</p> <p>You can have colored output. You can activate that by setting C<git hub configcolor auto>. It accepts the same values as C<git config color.ui> itself.</p> <p>=head1 Examples</p> <p>The following sections show lots of interesting ways to use C<git hub>. Let your imagination be your guide.</p> <p>=head2 Example 1. Create a new repo and GitHub origin</p> <p>Do everything from the command line:</p> <pre><code>$ mkdir foo $ cd foo $ git hub repo-init $ echo 'The new foo' > README $ git add README $ git commit -m 'First commit' $ git push origin main $ git hub repo-edit \ description 'The new foo' \ homepage http://example.com $ git hub repo</code></pre> <p>The C<repo-init> command will create a new GitHub repository using the directory name as the repo name. Note that on the last two commands you don't need to set the C<< <repo> >> because it can be gleaned from the remote. Also on the C<edit> command notice how you can specify multiple key/value pairs.</p> <p>To just create a new github repo without cloning it, use C<git hub repo-new>.</p> <p>=head2 Example 2. Commands from within a repo</p> <p>Assume your current working directory is not a GitHub repo:</p> <pre><code>$ # List *your* repos: $ git hub repos $ # Clone someone else's repo: $ git hub clone ingydotnet/git-hub $ # cd into it: $ cd git-hub $ # Get info about ingydotnet: $ git hub user $ # Show ingydotnet's recent repos: $ git hub repos $ # Show info about ingydotnet/git-hub: $ git hub repo $ # Fork the git-hub repo: $ git hub fork $ # Follow ingydotnet: $ git hub follow $ # See who ingydotnet is following: $ git hub following $ # Star the ingydotnet/git-hub repo: $ git hub star $ # etc...</code></pre> <p>The C<git hub> command tries to be environmentally aware. If you are in a GitHub cloned repo directory, and you don't specify C<< <user> >> or C<<<owner> >> or C<< <repo> >> for a command that needs them, then they will be pulled from the remote url. Otherwise, if you don't specify a C<< <user> >> it will use the one (presumably yours) that you set with the C<git hub configlogin ...> command.</p> <p>=head2 Example 3. Building Complex Commands</p> <p>The C<git hub> command can be used to output raw data, which can be fed into other commands; even other C<git hub> commands. This lets you do some powerful automation with very little code. The C<--raw> (C<-r>) flag will make the output of many commands be usable as data, and the C<-> (EACH) option makes commands read data from stdin.</p> <p>Get information about all your followers:</p> <pre><code>for user in $(git hub followers <your-login> -r); do git hub user $user done</code></pre> <p>Or more simply by using PIPE and EACH:</p> <pre><code>git hub followers -r | git hub user -</code></pre> <p>Follow all your followers:</p> <pre><code>git hub followers -r | git hub follow -</code></pre> <p>Find out if the people you are following, are following you!</p> <pre><code>git hub following -r | git hub follows -</code></pre> <p>View all the open issues on a repository at once:</p> <pre><code>git hub issues -r | git hub issue -</code></pre> <p>Clone all the repos in an organization:</p> <pre><code>git hub repos <org> -r | git hub clone -</code></pre> <p>Star the latest 5 repos from all the people you are following that have more than 50 repos:</p> <pre><code>git hub following <your-login> -r | git hub user-get - public_repos | perl -nle 'print if $_ > 50' | git hub repos - -rc5 | git hub star -</code></pre> <p>=head1 Author</p> <p>Written by Ingy döt Net <a rel="noreferrer nofollow" target="_blank" href="https://github.com/ingydotnet/git-hub/blob/main/mailto:ingy@ingy.net">ingy@ingy.net</a></p> <p>=head1 Status</p> <p>This command is over a year old. It does a ton of stuff well, but still has a lot to do to be complete.</p> <p>The plan is to support as much of the API as possible. Patches / Pull Requests welcome. See the file C<notes/todo> in the C<git-hub> repo for upcoming changes.</p> <p>Try C<make test>. There are tests in place but testing is not yet extensive. Expect more testing soon. Also please include tests-in-kind for any patches you submit.</p> <p>Find 'ingy' on #gitcommands in irc.freenode.net if you have questions or ideas.</p> <p>=head1 Copyright & License</p> <p>Copyright 2013-2016. Ingy döt Net.</p> <p>The MIT License (MIT)</p> <p>=cut</p></div> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>