git 密钥生成

501 阅读1分钟

// 生成密钥

ssh-keygen -t rsa -b 4096 -C "youremail@xx.com"
git config --global user.name "myusername" 
git config --global user.email "myusername@myemaildomain.com" 
git config --global credential.helper cache

git的常用命令如下

1.基本设置

$ git config --global user.name "liehuodadi"
$ git config --global user.email "email地址"

2. 生成密钥

$ ssh-keygen -t rsa -C “email地址”

3. 查看密钥

$ cat ~/.ssh/id_rsa.pub

4. 初始化本地仓库,在需要Git的文件夹上右键

$ git init

5. 添加码云上的远程项目(需要先在码云创件项目)

git remote add origin http网址hop_adaption

6. 下载远程项目到本地

git pull origin master

7. 上传及修改

git add .

8. 为上传的代码添加注释

$ git commit -m "first push"

9. 提交上传

$ git push origin master

以下这一条适用于重置本地文件。

10. 将云端文件全部强制覆盖本地所有文件(保持本地与云端相同)

git fetch --all && git reset --hard origin/master && git pull