git创建本地仓库,然后推送到github

先决条件,本地有git,自己拥有github账号

生成ssh公钥

这次我是在windows上进行的,在linux上也是差不多的。
在git bash

$ ssh-keygen -t rsa -C “youremail@example.com”

一路回车也行,我是一路回车

到这里可以查看到刚刚生成的公钥

cat ~/.ssh/id_rsa.pub

把公钥配置到github上去

登录自己github, 打开setings > SSH and GPG keys > New SSH key

Title 按照自己爱好写,key就把 ~/.ssh/id_rsa.pub里面的内容全部复制进来

然后Add SSH key就好了

最后测试一下连通性

$ ssh -T git@github.com

The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi magicmshing! You've successfully authenticated, but GitHub does not provide shell access.

出现这样的信息则表示成功

准备一个本地git仓库

  • 创建一个本地仓库
    进入想要作为git仓库的文件夹,输入git init就把整个当前文件夹变成一个git仓库了
 $ git init
Initialized empty Git repository in E:/minipro/Tm/.git/
  • 把需要上传的文件或者文件夹放在暂存区
$ git add .
warning: LF will be replaced by CRLF in app.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in app.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in app.wxss.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/index/index.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/index/index.wxml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/index/index.wxss.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/logs/logs.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/logs/logs.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/logs/logs.wxml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pages/logs/logs.wxss.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in project.config.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in utils/util.js.
The file will have its original line endings in your working directory.

. 是代表当前的全部文件和文件夹

  • 提交
$ git commit -m "first commit my wechat miniprogram"
[master (root-commit) d30833f] first commit my wechat miniprogram
 25 files changed, 293 insertions(+)
 create mode 100644 app.js
 create mode 100644 app.json
 create mode 100644 app.wxss
 create mode 100644 images/cloudy-bg.png
 create mode 100644 images/cloudy-icon.png
 create mode 100644 images/heavyrain-bg.png
 create mode 100644 images/heavyrain-icon.png
 create mode 100644 images/lightrain-bg.png
 create mode 100644 images/lightrain-icon.png
 create mode 100644 images/overcast-bg.png
 create mode 100644 images/overcast-icon.png
 create mode 100644 images/snow-bg.png
 create mode 100644 images/snow-icon.png
 create mode 100644 images/sunny-bg.png
 create mode 100644 images/sunny-icon.png
 create mode 100644 images/time-icon.png
 create mode 100644 pages/index/index.js
 create mode 100644 pages/index/index.wxml
 create mode 100644 pages/index/index.wxss
 create mode 100644 pages/logs/logs.js
 create mode 100644 pages/logs/logs.json
 create mode 100644 pages/logs/logs.wxml
 create mode 100644 pages/logs/logs.wxss
 create mode 100644 project.config.json
 create mode 100644 utils/util.js

推送到github

设置远程的起源

$  git remote add origin git@github.com:XXXXX/XXX.git

然后提交就好

$ git push -u origin master
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (32/32), 92.32 KiB | 153.00 KiB/s, done.
Total 32 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To github.com:magicmshing/Tm.git
   c4c56ce..0dbd8a6  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

首次需要-u ,之后提交就不需要了,这一步就要完了

emmm,可能你会遇到坑吧?

我吧我遇到的一个坑给你看看,就是$ git push -u origin master这一步出错的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

之芫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值