Skip to content

Commit dc15630

Browse files
authored
Improve login/enterprise docs
fix issue 257. move notes about github enterprise as a subtopic of Login (as half of it was there already anyway) add all the knowledge shared on issue 257 to the README.
1 parent 431ee0e commit dc15630

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,38 @@ an OAuth2 token (with the "gist" permission).
9292

9393
This token is stored in `~/.gist` and used for all future gisting. If you need to
9494
you can revoke it from https://github.com/settings/tokens, or just delete the
95-
file. If you need to store tokens for both github.com and a Github Enterprise instance
96-
you can save your Github Enterprise token in `~/.gist.github.example.com` where
97-
"github.example.com" is the URL for your Github Enterprise instance.
95+
file.
9896

9997
‌After you've done this, you can still upload gists anonymously with `-a`.
10098

10199
gist -a a.rb
102100

101+
### GitHub Enterprise
102+
103+
If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
104+
you need to export the `GITHUB_URL` environment variable (usually done in your `~/.bashrc`).
105+
106+
export GITHUB_URL=http://github.internal.example.com/
107+
108+
Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
109+
automatically use github enterprise instead of the public github.com
110+
111+
Your token for GitHub Enterprise will be stored in `.gist.<protocol><server.name>` (e.g.
112+
`~.gist.httpgithub.internal.example.com` for the GITHUB_URL example above) instead of `~/.gist`.
113+
114+
If you have multiple servers or use Enterprise and public GitHub often, you can work around this by creating scripts
115+
that set the env var and then run `gist`. Keep in mind that to use the public GitHub you must unset the env var. Just
116+
setting it to the public URL will not work. Use `unset GITHUB_URL`
117+
118+
### Token file format
119+
120+
If you cannot use passwords, as most Enterprise instalations do, you can generate the token via the web interface
121+
and then simply save the string in the correct file. Avoid line breaks or you migth see:
122+
```
123+
$ gist -l
124+
Error: Bad credentials
125+
```
126+
103127
# Library
104128

105129
‌You can also use Gist as a library from inside your ruby code:
@@ -131,16 +155,6 @@ NOTE: The access_token must have the "gist" scope.
131155
‌This will take them through the process of obtaining an OAuth2 token, and storing it
132156
in `~/.gist`, where it can later be read by `Gist.gist`
133157

134-
## GitHub enterprise
135-
136-
‌If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
137-
you need to export the `GITHUB_URL` environment variable in your `~/.bashrc`.
138-
139-
export GITHUB_URL=http://github.internal.example.com/
140-
141-
‌Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
142-
automatically use github enterprise instead of the public github.com
143-
144158
## Configuration
145159

146160
‌If you'd like `-o` or `-c` to be the default when you use the gist executable, add an

0 commit comments

Comments
 (0)