【经验分享】Git如何连接Github私有仓库

如何在 Linux 系统上连接和克隆 GitHub 私有仓库。

⚡ 省流版

bash 复制代码
# 更新包列表并安装必要工具
sudo apt update
sudo apt install -y git gh

# 登录 GitHub(浏览器授权)
gh auth login

# 让 git 使用 gh 的凭据
gh auth setup-git

# 克隆私有仓库(替换 OWNER 和 REPO)
git clone https://github.com/OWNER/REPO.git

📖 详细版

1、安装 gh 和 git

复制代码
sudo apt update
sudo apt install -y git gh

2、登录 GitHub(会引导你浏览器授权)

复制代码
gh auth login

gh auth login 默认是网页授权登录,并把 token 安全地存到系统凭据里

3、让 git 使用 gh 的凭据(可选但推荐)

复制代码
gh auth setup-git

(这是 GitHub CLI 提供的"把凭据接到 git"的步骤 )

4、克隆私有仓库

复制代码
git clone https://github.com/OWNER/REPO.git
# 或者你也可以用 SSH 地址(见方案B)
相关推荐
闲云一鹤2 小时前
Git LFS 扫盲教程 - 你不会还在用 Git 管理大文件吧?
前端·git·前端工程化
砖厂小工5 小时前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
程序员鱼皮5 小时前
又一个新项目完结,我要出海了!
ai·github·开源项目
徐小夕6 小时前
pxcharts-vue:一款专为 Vue3 打造的开源多维表格解决方案
前端·vue.js·github
Moment6 小时前
想要长期陪伴你的助理?先从部署一个 OpenClaw 开始 😍😍😍
前端·后端·github
我叫黑大帅6 小时前
前端如何利用 GitHub Actions 自动构建并发布到 GitHub Pages?
前端·面试·github
HelloGitHub8 小时前
这个年轻的开源项目,想让每个人都能拥有自己的专业级 AI 智能体
开源·github·agent
刘发财14 小时前
弃用html2pdf.js,这个html转pdf方案能力是它的几十倍
前端·javascript·github
sunny8651 天前
Claude Code 跨会话上下文恢复:从 8 次纠正到 0 次的工程实践
人工智能·开源·github