Git--上传自己的代码

今天玩了一下git上传自己的代码。
1.准备好Git账号+Git客户端。(百度)
2.在git网页端创建一个仓库。首页–New repository(左下方绿色按钮)–Repository name(你的仓库名)–Description (optional)(仓库描述,可填可不填)
–public(私有的要钱)–Create repository(下方绿色按钮)–仓库创建完毕。
3.打开git客户端–设置本地的ssh key,打开git bash,输入命令:

ssh-keygen -t rsa -C "1179229492@qq.com"  --其中双引号中是你注册github时用的邮箱

其中双引号中是你注册github时用的邮箱。一直回车,选择默认路径,和空密码。最后会在默认路径下生成.ssh文件夹,打开.ssh里面有两个文件,打开id_rsa.pub复制里面的密钥。
(我的:C:\Users\11792.ssh\id_rsa.pub)
4.打开github客户端–选择setting–ssh and gpg keys–New SSH key(右上方绿色按钮)–填写title-key(将自己刚才在id_rsa.pub文件里复制的密钥粘贴到key中)
5.查看是否成功。 回到git客户端,输入命令:

 ssh -T git@github.com

然后会显示提示,是否continue

The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? 

6 输入:yes,然后看到有Hi littlehubotao! You’ve successfully 就成功啦。不用理会warning

Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known                                                                                                                                   hosts.
Hi littlehubotao! You've successfully authenticated, but GitHub does not provide                                                                                                                                   shell access.

7.克隆你刚才新建的仓库到本地,输入命令:

git clone https://github.com/littlehubotao/hibernate-crud
//littlehubotao是我的git名。
//hibernate-crud是我的仓库名。

8.此时会在刚才创建ssh key的默认目录下生成以你仓库名为文件名的文件,
(在C:\Users\11792 下生成一个hibernate-crud文件)
9.在开发工具上面把自己的项目导在这个文件里面。
10.确保自己已经进入到文件的路径下。(刚才生成的hibernate-crud文件)。
如果不确定,输入命令:cd C:\Users\11792\hibernate-crud
11. 输入命令 :git init

//此时git还不知道你是谁   Please tell me who you are.

12.告诉git ,你的email 和 name.
你的email: git config --global user.email "1179229492@qq.com"
你的name: git config --global user.name "littlehubotao""
13.添加文件到git 输入命令 :.git add "hibernate_1"
14.commit文件 输入命令:git commit -m "这是我第一次提交代码到git"
15.输入命令:git push -u origin master //此操作目的是把本地仓库push到github上面,此步骤需要你输入帐号和密码
16.去git网页端看看。
参考1:https://blog.csdn.net/zhangsiyao11/article/details/77007684
参考2:https://blog.csdn.net/qq_32846595/article/details/71149312

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值