Step 1: Get an OAuth token
Create a personal access token on your application settings page. For more information, see "Creating a personal access token."
Tips:
- You must verify your email address before you can create a personal access token. For more information, see "Verifying your email address."
- 我们建议您定期审查您授权的集成。 删除在一段时间内未使用的任何应用程序和令牌。 更多信息请参阅“>审查授权的集成”。
作为安全防范措施,GitHub 会自动删除一年内未使用的个人访问令牌。 为了提供额外的安全性,我们强烈建议在您的个人访问令牌中添加到期日。
Step 2: Clone a repository
如果您有令牌,则可以在通过 HTTPS 执行 Git 操作时输入令牌,而不是密码。
例如,在命令行中输入以下内容:
$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token
To avoid these prompts, you can use Git password caching. For information, see "Caching your GitHub credentials in Git."
Warning: Tokens have read/write access and should be treated like passwords. If you enter your token into the clone URL when cloning or adding a remote, Git writes it to your .git/config file in plain text, which is a security risk.