📅  最后修改于: 2023-12-03 15:38:15.881000             🧑  作者: Mango
当你使用 Git 进行版本控制时,会经常与远程仓库进行交互,比如将本地代码推送到 GitHub 上。然而,每次执行推送操作时都需要输入用户名和密码,这很麻烦。为了简化流程,你可以在 Git 中设置全局的 GitHub 用户名和密码,这样以后就不用再次输入。
your_username
替换为你的 GitHub 用户名:git config --global user.name "your_username"
例如,如果你的用户名为 JohnDoe
,那么命令应该是这样的:
git config --global user.name "JohnDoe"
your_password
替换为你的 GitHub 密码:git config --global user.password "your_password"
注意:这里的密码并不是你 GitHub 账号的登录密码,而是访问代码仓库时所需的访问令牌(access token)。如果你还没有生成过访问令牌,请按照以下方式生成:
git config --global user.password "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
现在,你就可以愉快地使用 Git 进行代码版本控制了,Git 会自动读取你的全局用户名和密码。