如何在服务器上克隆、pull、push GitHub私有项目

发布时间:2026/8/23 14:12:02
如何在服务器上克隆、pull、push GitHub私有项目
诸神缄默不语-个人技术博文与视频目录我是在本地电脑上修改、开发应用代码然后想推送到GitHub私有仓库并在服务器上直接克隆、编辑、更新对应的项目。现在GitHub搞2FA认证了我是直接用谷歌浏览器存的Passkey。这块我就不介绍了。总之本文就只讲personal access token的事我执行git clone命令后会提示让我输入GitHub账号密码。以前是可以直接输入账号密码的但是现在我输入账密后它还是显示克隆失败并显示2024年12月的效果Cloning into folder_name... Username for https://github.com: user_name Password for https://user_namegithub.com: remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for https://github.com/user_name/folder_name.git/2026年8月的效果remote: Invalid username or token. Password authentication is not supported for Git operations. fatal: Authentication failed for https://github.com/user_name/folder_name.git/也就是说现在不支持仅用账号密码来克隆GitHub项目了解决方案是在输入密码时改为输入personal access token。获取personal access token的方式进入https://github.com/settings/personal-access-tokens现在personal access token分成fine-grained和classic两种。效果差不多我就只介绍fine-grained token了。创建token指定token名称会在token列表中看到方便明确哪个token是拿来干什么事的、token描述、过期时间、repository范围和权限想要正常执行clone、pull等操作就得给代码读写权限。这个resource owner我也不知道除了自己还能选谁我就是给自己用的所以还没有仔细研究。生成personal access token后点击复制即可注意这个token只会生成一次在token详情界面中也不能复制在token详情界面中可以续期。