很尴尬 用别的方式 解决掉了 上传都GitHub的问题
![](https://img.haomeiwen.com/i1373026/9b57af99aa55d623.jpeg)
1 .首先要有github账号吧,自行注册
2. 配置 ssh key
- 说明 git是分布式的代码管理工具,远程的代码管理是基于ssh的,所以要使用远程的git,需要配置ssh.
- 终端输入 defaults write com.apple.finder AppleShowAllFiles - bool true 作用是显示隐藏文件,然后前往个人文件夹看是否存在.ssh文件,有的话,删掉,没有更好。
![](https://img.haomeiwen.com/i1373026/d694b9b4df5f3956.png)
-
终端输入 mkdir .ssh (注意 mkdir 后有空格)
1
-
终端输入 cd .ssh
1
-终端输入 ssh-keygen -t rsa -C "645203735@qq.com" ,啥邮箱都可以,我用的是注册github的邮箱地址,回车
![](https://img.haomeiwen.com/i1373026/727bee130611359a.png)
-拷贝puh文件的内容 ,终端输入 pbcopy <~/.ssh/id_rsa.pub 之后直接粘贴就有了
![](https://img.haomeiwen.com/i1373026/11c1b23972b847e0.png)
-在自己github上填写ssh key
![](https://img.haomeiwen.com/i1373026/e49317b7644e613b.png)
![](https://img.haomeiwen.com/i1373026/6095dcb0fd351e66.png)
![](https://img.haomeiwen.com/i1373026/e72ffe8d94412141.png)
![](https://img.haomeiwen.com/i1373026/eba946d7823ad437.png)
![](https://img.haomeiwen.com/i1373026/fd190aa7f9f332d4.png)
![](https://img.haomeiwen.com/i1373026/76981f90e3f77460.png)
- 终端输入ssh -T git@github.com ,ssh配置完成
![](https://img.haomeiwen.com/i1373026/384804140909dd61.png)
3. 在github上新建一个仓库 New repository
-
新建仓库
1
![](https://img.haomeiwen.com/i1373026/4a810ee0be5a627e.png)
4.上传代码
- 首先进入你项目文件夹,终端输入 cd 你项目文件夹路径,紧接着初始化仓库,终端输入git init
![](https://img.haomeiwen.com/i1373026/cccdb90648754b6d.png)
![](https://img.haomeiwen.com/i1373026/a125f2717ae58c33.png)
- 告诉本地仓库你的github的邮箱和用户名,终端输入 git config -- global user.email "645203735@qq.com"
![](https://img.haomeiwen.com/i1373026/bafa964d10e576e1.png)
-
终端输入 git config --global user.name "wwq645"
1
-
提交仓库内容,终端输入 git commit -m "first commit" 住:'"first commit"之后是对本次提交的描述,可以修改,双印号不可省略 (这步错了 ,很尴尬 ,不知道为什么)
1
-
添加远程仓库并推送
-
1 添加远程仓库,终端输入 git remote add origin https:github.com/yyMae/Log-.git
注意:origin后面代表你github创建的仓库地址,
![](https://img.haomeiwen.com/i1373026/574b928a4c1f9bdf.png)
![](https://img.haomeiwen.com/i1373026/d6f89043f5929f78.png)
- 2 推动到远程仓库 ,终端输入 git push -u origin master,
网友评论