git管理gitee从入门

来源:互联网 发布:手机如何清除数据 编辑:程序博客网 时间:2024/06/09 18:41

1

下载git
若链接无效,百度一波。
安装

2

打开git bash 配置
执行命令

git config –global user.name “在gitee的名字或昵称”
git config –global user.email “gitee注册使用的邮箱”

然后在本地建立一个文件夹,(比如BookShopping),右键该文件夹,点击git bash,执行命令

git clone <项目地址>
比如
git clone https://gitee.com/hqweay/BookShopping.git

等克隆下来就可以修改项目代码了,

3 SSH公钥配置

本地生成SSH公钥,并在gitee配置。

Gitee帮助文件

打开git bash
配置你的相关信息

git config –global user.name “你的名字”

git config –global user.email “你的Email”

这一步是生成ssh公钥
连续按三次回车,使用默认配置即可

ssh-keygen -t rsa -C “xxxxx@xxxxx.com”

这一步是查询公钥,把显示的东西全复制下来复制下来
也可以打开C:\用户\Users.ssh中的id_rsa.pub文件
用记事本打开即可

cat ~/.ssh/id_rsa.pub

加下来在网站的配置SSH公钥处copy上即可。

然后就可以本地与云端同步啦。

clone下来的代码不能成功push

修改代码后不能push成功。

(协作项目其他人已取得管理权限等同理…)

Authentication failed for “https://gitee.com…..”

输入账号密码登录,出现这类报错。

使用SSH公钥可以让你在你的电脑和码云通讯的时候使用安全连接(Git的Remote要使用SSH地址)
gitee官方说明

因为克隆下来的代码默认以https方式与仓库关联,故重新关联。
先查询

git remote -v
若为
origin https://gitee.com/hqweay/BookShopping.git (fetch)
origin https://gitee.com/hqweay/BookShopping.git (push)
这类信息,则说明为https关联

先删除关联

git remote rm

查询是否删除成功

git remote -v
无信息则说明删除关联成功

再用SSH方式绑定,

git remote add origin git@gitee.com:hqweay/BookShopping.git

查询,若信息为

origin git@gitee.com:hqweay/BookShopping.git (fetch)
origin git@gitee.com:hqweay/BookShopping.git (push)

则ok,可以push代码了。

原创粉丝点击