@@ -77,24 +77,49 @@ To read a gist and print it to STDOUT
7777
7878See ` gist --help ` for more detail.
7979
80- ## Login
80+ ## Authentication
8181
82- If you want to associate your gists with your GitHub account, you need to login
83- with gist. It doesn't store your username and password, it just uses them to get
84- an OAuth2 token (with the "gist" permission).
82+ To associate and manage uploaded gists with your GitHub account, ` gist ` needs an
83+ authentication token, with at least the "gist" permission. The token can be
84+ obtained using ` gist --login ` . Alternately, you may generate a personal access
85+ token through https://github.com/settings/tokens and save it in ` ~/.netrc ` .
8586
86- gist --login
87+ ### Authenticating with ` gist --login `
88+
89+ Gist can login to your GitHub account. It doesn't store your Github username or
90+ password, it just uses them to get an OAuth2 token (with the "gist" permission).
91+
92+ $ gist --login
8793 Obtaining OAuth2 access_token from github.
8894 GitHub username: ConradIrwin
8995 GitHub password:
9096 2-factor auth code:
9197 Success! https://github.com/settings/tokens
9298
93- This token is stored in ` ~/.gist ` and used for all future gisting. If you need to
94- you can revoke it from https://github.com/settings/tokens , or just delete the
95- file.
99+ This token is stored in ` ~/.gist ` and used for all future gisting. The generated
100+ token will be listed in https://github.com/settings/tokens , and can also be
101+ revoked from there.
102+
103+ ### Credentials in ` ~/.netrc `
104+
105+ Gist can make use of a personal token stored in ` ~/.netrc ` . Github credentials
106+ stored in this file are matched by the hostname, and can be shared among
107+ different tools, like ` git ` , and ` curl ` .
108+
109+ The ` ~/.netrc ` file should be unreadable by anyone except the owner. To store
110+ your gist token in ` ~/.netrc ` , use the format:
96111
97- After you've done this, you can still upload gists anonymously with ` -a ` .
112+ machine github.com
113+ password PERSONAL_ACCESS_TOKEN
114+
115+ You may also maintain a separate token exclusively for gisting by associating
116+ the token with the hostname ` gist.github.com ` , and setting the environment
117+ variable ` GITHUB_URL=https://gist.github.com ` .
118+
119+ ### Uploading anonymous gists
120+
121+ Independently of the authentication mechanism used, you can always upload gists
122+ anonymously by using the ` -a ` option.
98123
99124 gist -a a.rb
100125
@@ -103,13 +128,19 @@ file.
103128If you'd like ` gist ` to use your locally installed [ GitHub Enterprise] ( https://enterprise.github.com/ ) ,
104129you need to export the ` GITHUB_URL ` environment variable (usually done in your ` ~/.bashrc ` ).
105130
106- export GITHUB_URL=http ://github.internal.example.com/
131+ export GITHUB_URL=https ://github.internal.example.com/
107132
108133Once you've done this and restarted your terminal (or run ` source ~/.bashrc ` ), gist will
109134automatically use github enterprise instead of the public github.com
110135
111- Your token for GitHub Enterprise will be stored in ` .gist.<protocol>.<server.name>[.<port>] ` (e.g.
112- ` ~.gist.http.github.internal.example.com ` for the GITHUB_URL example above) instead of ` ~/.gist ` .
136+ When using ` gist --login ` your token for GitHub Enterprise will be stored in
137+ ` .gist.<protocol>.<server.name>[.<port>] ` (e.g.
138+ ` ~.gist.https.github.internal.example.com ` for the GITHUB_URL example above)
139+ instead of ` ~/.gist ` . The token can also be stored in ` ~/.netrc ` with an
140+ appropriate entry for the host. For instance, for the example above,
141+
142+ machine github.internal.example.com
143+ password GITHUB_ENTERPRISE_TOKEN
113144
114145If you have multiple servers or use Enterprise and public GitHub often, you can work around this by creating scripts
115146that set the env var and then run ` gist ` . Keep in mind that to use the public GitHub you must unset the env var. Just
0 commit comments