git 安装和使用

1、安装

官方下载地址:https://git-scm.com/downloads  选择对应的系统点击下载安装即可

2、配置

   (前提你得有自己的github账户)进入https://github.com/new 创建一个代码仓

然后打开本地 git软件   

 

   设置全局配置 

git config --global user.name "your name" 
git config --global user.email "your email"
d: 首先进入项目磁盘 然后cd aaa/aaa 进入到项目文件夹
git init  //初始化本地文件
git add README.md  
git commit -m "first commit"
git remote add origin git@github.com:用户名/xxxx.git
(xxx.git这个是你代码仓的地址上面有提到首先要去新建一个代码仓)
git push -u origin master //提交到你的代码仓

  

git push -u origin master 如果这一步报这个错误(Please make sure you have the correct access rights and the repository exist)

这个问题是因为没有配置SSH key 请按照以下操作解决这个问题

首先打开
git bash 这个窗口 然后输入 ssh-keygen -t rsa -C "123@163.com"(请填你设置的邮箱地址)

接着出现:

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

  

请直接按下回车

然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub


默认情况下是生成在C:\Users\您的计算机名\.ssh 这个地址下 id_rsa.pub 用编辑器打开这个文件 复制里面的内容


打开https://github.com/,登陆你的账户,进入设置

 

进入ssh设置

 

在key中将刚刚复制的粘贴进去

点击add ssh key就可以了 然后在git cmd窗口下重新执行  git push -u origin master 就可以了

 

posted @ 2018-01-18 17:39  bohew  阅读(129)  评论(0编辑  收藏  举报