在Ubuntu上创建Git仓库并上传到GitHub

这里写图片描述

1、安装 Git

$ sudo apt-get install git git-core

  检查:git --version

2、基本配置

$ git config --global user.name <your-name>
$ git config --global user.email <your-email>

3、假设项目名为 helloworld,执行下面命令,进到项目目录,创建版本库

$ cd helloworld
$ echo "# helloworld" >> README.md
$ git init

4、Staging 被修改的文件,并提交更新

$ git add .
$ git commit -m "first commit"

5、仓库托管到 GitHub,需要 SSH Key 验证,执行下面命令创建 SSH Key

$ ssh-keygen -t rsa

  之后在 ~/.ssh/ 目录下可以看到 id_rsaid_rsa.pub 两个文件。这两个就是 SSH Key 的秘钥对,其中,id_rsa 是私钥,不能泄露出去,id_rsa.pub 是公钥,可以放心地告诉任何人。

6、然后登陆 GitHub,上传 SSH Key 公钥

  依次选择“Settings –> SSH and GPG keys –> New SSH key”,填上适当的 Title,并复制 id_rsa.pub 文件的内容粘贴在 Key 文本框里。

7、在 GitHub 上新建一个仓库(假设名为 helloworld),然后执行如下命令

$ git remote add origin https://github.com/<your-name>/helloworld.git

8、接着,就可以把本地仓库的所有内容推送到远程仓库

$ git push -u origin master

可能遇到的问题:

1、remote: fatal: early EOF

  在repo sync 时,,出现“remote: fatal: early EOF”错误,解决方法是修改家目录下 .gitconfig 文件,添加如下内容:

[core]
    compression = -1

2、提示如下警告

remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: warning: See http://git.io/iEPt8g for more information.
remote: warning: File xxx is 55.80 MB; this is larger than GitHub’s recommended maximum file size of 50.00 MB

  这是因为有的文件大小超过 50 MB,参考说明,可知:GitHub will warn you when pushing files larger than 50 MB. You will not be allowed to push files larger than 100 MB.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

阿基米东

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

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

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

打赏作者

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

抵扣说明:

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

余额充值