Skip to content

Commit 11c38ac

Browse files
authored
Merge pull request #1879 from hjwp/all-in-on-personal-access-tokens
Tell people to create a GitHub Personal Access Token up-front
2 parents f0b12e4 + b6a8f96 commit 11c38ac

File tree

1 file changed

+29
-41
lines changed

1 file changed

+29
-41
lines changed

en/deploy/README.md

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,23 @@ $ git commit -m "My Django Girls app, first commit"
132132

133133
## Pushing your code to GitHub
134134

135-
Go to [GitHub.com](https://www.github.com) and sign up for a new, free user account. (If you already did that in the workshop prep, that is great!) Be sure to remember your password (add it to your password manager, if you use one).
135+
Go to [GitHub.com](https://www.github.com) and sign up for a new, free user account.
136+
(If you already did that in the workshop prep, that is great!)
137+
Be sure to remember your password (add it to your password manager, if you use one).
136138

137-
Then, create a new repository, giving it the name "my-first-blog". Leave the "initialize with a README" checkbox unchecked, leave the .gitignore option blank (we've done that manually) and leave the License as None.
139+
### Creating a Personal Access Token
140+
141+
Now follow the instructions from GitHub to [create a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).
142+
The token should have the 'repo' scope.
143+
Copy the value of the token, and save it somewhere safe (like a password manager).
144+
145+
### Creating a new repository
146+
147+
Back on the GitHub homepage,
148+
create a new repository, giving it the name "my-first-blog".
149+
Leave the "initialize with a README" checkbox unchecked,
150+
leave the .gitignore option blank (we've done that manually)
151+
and leave the License as None.
138152

139153
![](images/new_github_repo.png)
140154

@@ -146,52 +160,22 @@ On the next screen, you'll be shown your repo's clone URL, which you will use in
146160

147161
Now we need to hook up the Git repository on your computer to the one up on GitHub.
148162

149-
Type the following into your console (replace `<your-github-username>` with the username you entered when you created your GitHub account, but without the angle-brackets -- the URL should match the clone URL you just saw).
163+
Type the following into your console
164+
(replace `<your-github-username>` with the username you entered when you created your GitHub account,
165+
but without the angle-brackets -- the URL should match the clone URL you just saw).
150166

151167
{% filename %}command-line{% endfilename %}
152168
```
153169
$ git remote add origin https://github.com/<your-github-username>/my-first-blog.git
154170
$ git push -u origin HEAD
155171
```
156172

157-
When you push to GitHub, you'll be asked for your GitHub username and password (either right there in the command-line window or in a pop-up window), and after entering credentials you should see something like this:
158-
159-
{% filename %}command-line{% endfilename %}
160-
```
161-
Counting objects: 6, done.
162-
Writing objects: 100% (6/6), 200 bytes | 0 bytes/s, done.
163-
Total 3 (delta 0), reused 0 (delta 0)
164-
To https://github.com/ola/my-first-blog.git
165-
* [new branch] main -> main
166-
Branch main set up to track remote branch main from origin.
167-
```
173+
When you push to GitHub, you'll be asked for your GitHub username and password
174+
(either right there in the command-line window or in a pop-up window).
175+
Use the Personal Access Token you created earlier,
176+
not your account password.
168177

169-
**Note** You will likely encounter the following error when trying to push to GitHub:
170-
```
171-
remote: Support for password authentication was removed on August 13, 2021.
172-
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
173-
fatal: Authentication failed for 'https://github.com/<your-github-username>/my-first-blog.git/'
174-
```
175-
In this case, follow the instructions from GitHub to [create a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic). The token should have the 'repo' scope. Copy the value of the token, then try the git push command again. When you are prompted to enter your username and password, enter the access token instead of your password:
176-
177-
1. Go to profile settings or go here: https://github.com/settings/profile
178-
2. Scroll down and click "Developer settings" on left-hand menu or go here: https://github.com/settings/apps
179-
3. On left-hand menu, press "Personal access tokens" to expand the dropdown menu. Click "Tokens (classic)"
180-
4. In the top-right, click "Generate new token", and then click "Generate new token (classic)". You will need to authenticate your account at this point.
181-
5. Fill in the form:
182-
- Note: Django girls blog
183-
- Expiration: No expiration (or if you want more security, choose 90 days)
184-
- Select scopes: Check every box
185-
6. Press "Generate token"
186-
7. Copy the token generated (it's the text string that likely starts with `ghp...`) and store this token somewhere secure as once you close this page, you will lose access to viewing this token and will need to generate a new one if you lose it. For example, you could store it in a password manager or even in a note on your computer.
187-
8. Run the command in the terminal again:
188-
{% filename %}command-line{% endfilename %}
189-
```
190-
$ git push -u origin HEAD
191-
```
192-
9. When the terminal asks for `username`, enter in your github username. Press enter.
193-
10. Next, it will ask for `password`. Do not use your github password as this method of authenticating ("logging in") is deprecated. Copy the token you just generated (either from github or wherever you carefully stored this token) and carefully paste it into the terminal. Note that as you paste or even type into the terminal for the password, nothing will appear (you can't see what you typed) for security reasons (it's designed like this on purpose). Press enter.
194-
11. If that worked, you will see the output as below. If you are unsuccesful, try to run `git push -u origin HEAD` again and make sure that you enter in your github username and the token (as the password) correctly.
178+
After entering credentials you should see something like this:
195179

196180
{% filename %}command-line{% endfilename %}
197181
```
@@ -205,10 +189,14 @@ Branch main set up to track remote branch main from origin.
205189

206190
<!--TODO: maybe do ssh keys installs in install party, and point ppl who dont have it to an extension -->
207191

208-
Your code is now on GitHub. Go and check it out! You'll find it's in fine company – [Django](https://github.com/django/django), the [Django Girls Tutorial](https://github.com/DjangoGirls/tutorial), and many other great open source software projects also host their code on GitHub. :)
192+
Your code is now on GitHub. Go and check it out!
193+
You'll find it's in fine company – [Django](https://github.com/django/django),
194+
the [Django Girls Tutorial](https://github.com/DjangoGirls/tutorial),
195+
and many other great open source software projects also host their code on GitHub. :)
209196

210197
{% include "/deploy/pythonanywhere.md" %}
211198

199+
212200
# Check out your site!
213201

214202
The default page for your site should say "It worked!", just like it does on your local computer. Try adding `/admin/` to the end of the URL, and you'll be taken to the admin site. Log in with the username and password, and you'll see you can add new Posts on the server -- remember, the posts from your local test database were not sent to your live blog.

0 commit comments

Comments
 (0)