频道栏目
首页 > 资讯 > 其他综合 > 正文

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

17-04-12        来源:[db:作者]  
收藏   我要投稿
在Ubuntu上创建Git仓库并上传到GitHub:希望下面的文章对大家有所帮助。

1、安装 Git

$ sudo apt-get install git git-core

  检查:git --version

2、基本配置

$ git config --global user.name 
$ git config --global user.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_rsa 和 id_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//helloworld.git

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

$ git push -u origin master

可能遇到的问题:

1、remote: fatal: early EOF

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

[core]
    compression = -1

 这是因为有的文件大小超过 50 MB。

相关TAG标签
上一篇:今日头条决战BAT+微信+微博,重审这家110亿美金新巨头
下一篇:LNMP配置NamecheapComodoSSL证书教程
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站