Handle GitHub Password Authentication Deprecation


Recently, GitHub deprecated the use of password for repos. You will have to generate GitHub tokens to access repos. It’s difficult for me to memorize the token without serious efforts. Fortunately, it’s easy to mitigate the problem.

After a repo is cloned, simply execute git remote remove origin to remote the old remote. Then, execute the following command:

git remote add origin https://<TOKEN>@github.com/<GITHUB_USERNAME>/<REPO>.git

Finally, execute the following command to setup upstream:

git push --set-upstream origin main

After this, no password is needed for git operations inside this repo. Beware you need to perform this operation for every new repo.