Github创建项目并使用git将本地项目push到github

目录(?)[+]

一. 创建地址github

1. Set up your personal account

填写自己点用户名、邮箱地址、密码

2. Create a new repository

填写自己的项目名称和描述

3. 复制自己的项目地址

我自己的项目地址


二. 下载git forWindows

git for windows

要翻墙才能下载,也可以通过别的方式下载

国内下载

下载后有

  • git bash – linux
  • git cmd – windows
  • git gui – 可视化操作

建议使用Git cmd /git bash


三. 创建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 "yxzhong"
$ git config --global user.email "your email"
   
   
  • 1
  • 2
  • 1
  • 2
  • 查看是否已经存在ssh key是否存在
$ cd ~/.ssh
   
   
  • 1
  • 1

–> 如果没有则提示: No such file or directory 
–> 如果有则进入~/.ssh路径下(ls查看当前路径文件,rm * 删除所有文件)生成新的ssh key

  • 生成ssh key
cd ~ //保持在"~"目录下
$ ssh-keygen -t rsa -C "xxxxxx@yy.com"//填写真实的邮箱
   
   
  • 1
  • 2
  • 1
  • 2
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa):   #不填直接回车
Enter passphrase (empty for no passphrase):   #输入密码(可以为空)
Enter same passphrase again:   #再次确认密码(可以为空)
Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa.   #生成的密钥
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub.  #生成的公钥
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 添加ssh key到github

—>打开github→Settings→SSH kyes→Add SSH key

–>1. 进入c:/Users/xxxx_000/.ssh/目录下,打开id_rsa.pub文件,全选复制公钥内容 
–>2. Title自定义,将公钥粘贴到GitHub中Add an SSH key的key输入框,最后”Add Key”

  • 测试ssh key是否设置成功
$ ssh -T git@github.com
   
   
  • 1
  • 1
The authenticity of host 'github.com (192.30.252.129)' 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.252.129' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa':  #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码即可。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现词句话,说明设置成功。
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

四. 将本地项目push到github(git cmd为例)

  • 打开git cmd 将路径设置到项目路径
  • 初始化项目
git init
   
   
  • 1
  • 1
  • 添加远程仓库
git remote add origin git@github.com:michaelliao/learngit.git //你自己的地址
   
   
  • 1
  • 1
  • push本地项目到远程仓库
git add . //添加所有本地代码到缓冲区
git commit -m "describe message"
git push -u origin master//origin也可以自己命名远程仓库名称
   
   
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3
  • 在github查看自己的项目是否传上去 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值