Git push 的时间必要输入用户名和暗码办理方案

[复制链接]
发表于 2026-1-28 05:54:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

1. 标题

在使用 git push -u origin main 下令推送长途分支时要求输入用户名和暗码,详细操纵如下所示:
  1. (base) localhost:profile-platform wy$ git branch -M main
  2. (base) localhost:profile-platform wy$
  3. (base) localhost:profile-platform wy$ git remote add origin https://github.com/sjf0115/profile-platform.git
  4. (base) localhost:profile-platform wy$
  5. (base) localhost:profile-platform wy$ git push -u origin main
  6. Username for 'https://github.com':
复制代码
2. 办理方案

缘故起因是在添加长途库的时间使用了 https 的方式。以是使用的 https 的方式 push 到长途库。只必要重新设置成 ssh 的方式即可:
  1. (base) localhost:profile-platform wy$ git remote add origin [email protected]:sjf0115/profile-platform.git
  2. (base) localhost:profile-platform wy$
  3. (base) localhost:profile-platform wy$ git push -u origin main
  4. Enumerating objects: 21, done.
  5. Counting objects: 100% (21/21), done.
  6. Delta compression using up to 4 threads
  7. Compressing objects: 100% (12/12), done.
  8. Writing objects: 100% (21/21), 8.17 KiB | 1.63 MiB/s, done.
  9. Total 21 (delta 0), reused 0 (delta 0), pack-reused 0
  10. To github.com:sjf0115/profile-platform.git
  11. * [new branch]      main -> main
  12. branch 'main' set up to track 'origin/main'.
复制代码
如下图所示有 https 和 ssh 两种方式,我们选择 ssh 方式即可:

回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表