Git 关联 Gitee 仓库 - 详细步骤与命令
要将本地 Git 与 Gitee 上的仓库关联起来,可以按照以下步骤操作:
-
在 Gitee 上创建一个新的仓库,或者打开已有的仓库。
-
复制仓库的 SSH 或 HTTPS 地址,例如:'git@gitee.com:username/repo.git' 或 'https://gitee.com/username/repo.git'。
-
在本地终端或 Git 客户端中,进入要关联的本地 Git 仓库所在的目录。
-
运行以下命令来添加远程仓库的地址:
# 使用 SSH 地址
git remote add gitee git@gitee.com:username/repo.git
# 使用 HTTPS 地址
git remote add gitee https://gitee.com/username/repo.git
- 确认关联是否成功,可以运行以下命令查看远程仓库列表:
git remote -v
输出结果中应该包含关联的 'gitee' 远程仓库信息。
现在可以通过 git push 命令将本地代码推送到 Gitee 上的仓库中了。例如,运行以下命令将本地的 'master' 分支推送到 Gitee:
git push gitee master
在推送代码时,可能需要输入 Gitee 的用户名和密码或者 SSH 私钥密码,以进行身份验证。
原文地址: https://www.cveoy.top/t/topic/lKsC 著作权归作者所有。请勿转载和采集!