HTTPS is a method to authenticate your local Git with your GitHub account over the internet using a Personal Access Token (PAT) instead of a password.
GitHub no longer allows you to use your account password when pushing code from the terminal for security reasons. You must use a Personal Access Token (PAT) if you connect via HTTPS.
When you clone a repository via HTTPS, the URL looks like this:
git clone https://github.com/USERNAME/REPOSITORY.git- Go to GitHub Settings -> Developer Settings -> Personal access tokens -> Tokens (classic).
- Click Generate new token.
- Give it a note (e.g., "Laptop Git").
- Check the
reposcope (this gives it permission to push/pull code). - Click generate and copy the token.
When you push code and the terminal asks for a password, paste this token instead.
- Closing the page before copying: GitHub only shows the token once. If you lose it, you have to generate a new one.
- Typing password instead of token: Using your normal GitHub login password in the terminal will fail with an "Authentication failed" error.
- Passwords don't work in the terminal anymore.
- Generate a Personal Access Token (PAT) in GitHub settings.
- Check the
repopermission when creating the PAT. - Use the PAT whenever Git asks for a password.