git将本地项目push到github
1.Git]下载地址
git官网是需要翻墙才能下载的,里给出Git-2.9.2-64-bit下载地址(我的是64位系统): Git-2.9.2-64-bit
下载后安装步骤可以参考这里:Win7下Git的安装
2. 创建ssh key–安全传输
- 方法1. 使用git gui 直接生成
打开git gui help – show ssh key
- *方法2. 使用git bash/git cmd 创建(git bash 为例 )*>设置git的user.name和user.email
$ git config --global user.name "wblearn" $ git config --global user.email "your email"
>查看是否已经存在ssh key是否存在$ cd ~/.ssh
![以上步骤截图](http://upload-images.jianshu.io/upload_images/2556999-463b8867c3907ef7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)**如果没有则提示: No such file or directory 如果有则进入~.ssh路径下(ls查看当前路径文件,rm * 删除所有文件)生成新的ssh key**
>生成ssh keycd ~ //保持在"~"目录下 $ ssh-keygen -t rsa -C "xxxxxx@qq.com"//填写真实的邮箱
Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa): #不填直接回车 Enter passphrase (empty for no passphrase): #输入密码(可以为空) Enter same passphrase again: #再次确认密码(可以为空) Your identification has been saved in /c/Users/xxxx/.ssh/id_rsa. #生成的密钥 Your public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub. #生成的公钥
![以上步骤截图](http://upload-images.jianshu.io/upload_images/2556999-63e1cdae6971a986.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)>添加ssh key到github1.打开github→Settings→SSH kyes→Add SSH key 2.进入c:/Users/xxxx/.ssh/目录下,打开id_rsa.pub文件,全选复制公钥内容 3.Title自定义,将公钥粘贴到GitHub中Add an SSH key的key输入框,最后”Add Key”
测试ssh key是否设置成功
$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.113)' can't be established. RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yes Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts. Enter passphrase for key '/c/Users/xxxx/.ssh/id_rsa': #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码即可。 Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现词句话,说明设置成功。
3.将本地项目push到github(git cmd为例)
打开git cmd 将路径设置到项目路径
初始化项目
git init
>添加远程仓库git remote add origin "你自己仓库的地址"
>push本地项目到远程仓库git add . //添加所有本地代码到缓冲区 git commit -m "first commit"//描述信息 git push -u origin master//origin也可以自己命名远程仓库名称