add token to cli git 1

add token to cli git

git remote add origin https://[USERNAME]:[NEW TOKEN]@github.com/[USERNAME]/[REPO].git
//how to generate token : https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
//or if you have set origin before 
git remote set-url origin https://[USERNAME]:[NEW TOKEN]@github.com/[USERNAME]/[REPO].git

Here is what the above code is Doing:
1. git remote add origin https://[USERNAME]:[NEW TOKEN]@github.com/[USERNAME]/[REPO].git
– This adds a new remote to your local repository.
– The remote is called “origin” and points to your GitHub repository.
– The URL is the HTTPS URL of your GitHub repository.
– The URL includes your GitHub username and a personal access token.
2. git remote set-url origin https://[USERNAME]:[NEW TOKEN]@github.com/[USERNAME]/[REPO].git
– This changes the URL of the “origin” remote.
– The URL is the HTTPS URL of your GitHub repository.
– The URL includes your GitHub username and a personal access token.

Similar Posts