在Ubuntu上创建Git仓库并上传到GitHub
2017-04-11 02:48
183 查看
![](http://a.36krcnd.com/photo/d31f9c5bcb2cc8d64f2d789dcc7fc9d5.png!heading)
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_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/<your-name>/helloworld.git[/code]
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.
相关文章推荐
- Ubuntu创建Git仓库并上传到GitHub
- 用git 命令创建本地仓库将本地代码上传到github
- git创建本地仓库并且上传到github
- 利用git for windows 图形界面工具创建仓库并上传项目到webgitHub
- Git――新手入门与上传项目到远程仓库GitHub(转)
- Git——新手入门与上传项目到远程仓库GitHub(转)
- Git新手入门与上传项目到远程仓库GitHub
- Git 创建本地仓库并上传到远程仓库
- 怎么用git bash上传本地项目代码到您的github仓库1
- Git——新手入门与上传项目到远程仓库GitHub(转)
- Git——新手入门与上传项目到远程仓库GitHub
- Github 创建仓库、上传本地项目图文教程
- 【Git学习笔记】GitHub中创建仓库,将本地仓库推送到远程库
- 代码上传到github,gitlab等git仓库进行托管
- github创建仓库及上传文件
- Git——新手入门与上传项目到远程仓库GitHub(转)
- Git 菜鸟变大神 (四)Github 创建远程仓库以及关联本地仓库
- git 第二天 注册git服务端(github)并创建远程仓库
- 将本地创建的工程上传到github仓库中
- git 创建仓库并提交到github