As I kept running into GitHub auth issues on each new local setups, I documented the steps here.
This gist documents how to set up your local dev env, especially on a headless Ubuntu machine, to push local Git changes to remote GitHub repositories.
It features
- fine-grained auth token
- headless env, e.g. remote ubuntu dev machine, where browser-based auth does not work well
To acquire the permission to push local changes to the remoate GitHub repos.
- Create a personal access token in your GitHub website.
- [Your profile icon] --> [Personal access tokens] --> [Fine-grained tokens] --> [Generate new token]
- Fill out "Token name" and "Expiration".
- Select
All repositoriesfor "Repository access". - In the "Permissions" section, click on "+ Add permissions" button
- Select
ContentswithRead and writeaccess. This should give you permissions to push changes to GitHub.
- Select
- Click "Generate token" and store the token in a safe place(e.g. 1Password).
- Install gh-cli locally.
- Login
ghwith the previous personal access token
gh auth login
## Here is an example of my personal setup
# Where do you use GitHub? --> GitHub
# What is your preferred protocol for Git operations on this host? --> HTTPS
# How would you like to authenticate GitHub CLI? --> Paste an authentication token (the personal access token)- Make Git use GitHub CLI’s credential helper.
gh auth setup-git
# Now you should be able to push changes
git push