Github是面向开源和私有的代码管理平台。支持git分布式版本管控系统。
Github的作用:
- 代码托管:把代码备份到github上。
- 项目管理:基于Git分布式版本管理系统。他对项目的每一个版本以及每个版本修改的内容有完整的记录。
- 装大神。
登录后进入主页,点击右上角的➕号在弹出的子菜单中选New repository(新建仓库)
跳转到配置repository(仓库)的界面
添加仓库完成后点击Clone or download 在弹出框中获取到repository(仓库)的地址
之后就可以在本地使用git命令把项目push到Github上
如果是第一次上传
echo "# CqtekApp_iOS" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/youraccount/yourprojects.git
git push -u origin master
如果是多人合作的项目,在上传代码前,先把github上的代码pull到本地,push上区
$ git pull
$ git push -u origin master -f
关于报错:
如果执行
git remote add origin https://github.com/youraccount/yourprojects.git
报错
fatal: remote origin already exists.
意思已经很明显,之前已经配置过项目的github上的仓库。 处理方法是,先移除仓库,在终端项目根目录执行
$ git remote rm origin
(待更新)