swsrl 发表于 2018-1-12 20:38:57

git入门使用摘录

  无论使用github或者gitlab,第一步都是在本地生产ssh-key,ssh-key作为客户端的身份证存放在user用户的.ssh文件夹下。如果之前没有生产过,需要用ssh-keygen命令生成。创建完后,把公共密钥加到github或者gitlab的ssh-key配置中。
  简单说就是,创建ssh-key - git站点上添加公钥
  详细步骤如下
  1. 创建密钥,在创建之前先检查下密钥是否已经存在
  使用   cd ~/.ssh, 如果无此文件夹就是之前没有创建过
  现在使用ssh-keygen创建密钥,注意-C是大写,-t可以不写,默认类型就是rsa
  

ssh-keygen -t rsa -C "your_email@example.com"  
# Creates a new
ssh key using the provided email  
Generating public
/private rsa key pair.  
Enter
file in which to save the key (/your_home_path/.ssh/id_rsa):  

  2. 在站点上设置密钥,在profile的ssh-key选项里,不截图了(另外一篇关于gitgui使用的里有截图),一定要添加公钥,.ssh文件夹下.pub结尾的
  第二步完成,已经配置成了,来试试拉一个项目下来。
  在下载的本地文件夹中更改或者新建一个文件,scan后,git会识别到新文件,通过然后 stage changed,commit,push三个步骤完成更新。在commit时候有可能遇到user.name和user.email未设置的报错,根据提示在git命令行中设置一下git config --global user.email "your_email@example.com" 和 user.name
  stage changed 可以被理解为缓存状态
  commit 是本地提交
  push 提交到远端仓库
页: [1]
查看完整版本: git入门使用摘录