GitHub and Personal access tokens
October 2, 2021
home
Contents
01. GitHub and a security change in Aug.13, 2021
- GitHub is the recognized website providing the service for code remote repository.
- To begin with, create your GitHub account.
- From 8/13/021, to access a repository in GitHub, password authentication was removed, personal access token is needed instead.
02. Create personal access token and save it
- In your github page, at the top-left corner, click the dropdown button, select item settings.
- On the left of your github page, list Account settings shows up.
- Click list item Developer settings.
- In Settings/Developer settings, select list item Personal access tokens.
- On its top-left corner, click button Generate new token.
- The token is created. The value is returned, save it in a private location.
- note: Later, you can recreate a new one.
- You use this token to access your Github repositories.
- Your team memeber can also use this token to do so.
03. Using the token for push
- First, your project is well developed.
- In your GitHub page, create a repostiory, with a name.
- Back to your terminal window, enter the push command as below:
- $git push https://ghp_xxx@github.com/johndoe/projectxyz.git
- Token value: ghp_xxx
- GitHub owner name: johndoe
- repository name: projectxyz
- Switch to your github page, select the repository to confirm the action.
- note: from local main branch to remote main branch
- For mac user, you use the token to access the github repository just once.
- When accessing by push with a token, which will be automatically installed in your mac keychanin.
- This is the way to add the token in your mac.
- After the first acces, there is no need providing the token for access.
04. Verify personal access token in your mac keychain
- For mac, there are many different os and types. And there are many ways to do one task.
- In my finder window, in Application/Utilities/KeyChan Access, double click it to open.
- On the left, in Keychains, select login, in category, select Password.
- The the list of Name, find gitcom. Double click it.
- A dialogbox shows up, asking for password, I used my mac login passworld.
- In the text box for show password, you see the token value.
- It should be the same as the one, which was created by you in github
05. Using the token in keychain for pull and push
- Two examples are listed as below:
- $git pull https://github.com/johndoe/repositoryxyz.git
- $git push --set-upstream https://github.com/johndoe/repositoryxyz.git master