Git使用入门 - 在Git上新建项目
2015-12-23 13:56
543 查看
Git的使用很简单,第一次在客户端获取代码时,直接通过各种IDE的clone方法,可以把Git上的工程get下来即可。后续使用时,新文件用 add、commit、push;获取新版本用 pull 或 fecth,遇到冲突就 merge 一下。
Git首次创建略麻烦。过程大致如下:
在OSChina上创建Git项目。
在本地装好 git 工具,安装好后,会有2个可执行文件,Git GUI 和 Git Bash ,正如名称一样,一个是GUI工具,一个是命令行工具。
在本地项目的文件夹中(是否有文件都可以),右键菜单,执行 Git Bash,会进入命令行工具,自动定位在本目录下了。
进行初始化: git init
添加当前所有文件: git add . ( . 代表目录下所有文件)
首次提交: git commit -m 'initial commit'
添加远程仓库: git remote add origin https://git.oschina.net/xxx/xxx.git
提交远程前校对: git fetch origin master
提交远程前抓取: git pull origin master
将本地提交,推送到远程仓库: git push origin master
Ps. 如果报错:
报错信息:Updates were rejected because the tip of your current branch is behind,its remote counterpart. Integrate the remote changes (e.g. 'git pull ...') before pushing again.
解决方案:先执行 git branch --set-upstream master origin/master ,执行结果:Branch master set up to track remote branch master from origin. 然后再进入第8步。
Git首次创建略麻烦。过程大致如下:
在OSChina上创建Git项目。
在本地装好 git 工具,安装好后,会有2个可执行文件,Git GUI 和 Git Bash ,正如名称一样,一个是GUI工具,一个是命令行工具。
在本地项目的文件夹中(是否有文件都可以),右键菜单,执行 Git Bash,会进入命令行工具,自动定位在本目录下了。
进行初始化: git init
添加当前所有文件: git add . ( . 代表目录下所有文件)
首次提交: git commit -m 'initial commit'
添加远程仓库: git remote add origin https://git.oschina.net/xxx/xxx.git
提交远程前校对: git fetch origin master
提交远程前抓取: git pull origin master
将本地提交,推送到远程仓库: git push origin master
Ps. 如果报错:
报错信息:Updates were rejected because the tip of your current branch is behind,its remote counterpart. Integrate the remote changes (e.g. 'git pull ...') before pushing again.
解决方案:先执行 git branch --set-upstream master origin/master ,执行结果:Branch master set up to track remote branch master from origin. 然后再进入第8步。
相关文章推荐
- RPC failed; result=22, HTTP code = 411
- git更新已經刪除的文件
- 提取Git每次提交后Commit的文件
- GIT迁移服务器
- 分布式版本管理git入门指南使用资料汇总及文章推荐
- git终极指南:在实际开发中的应用
- 解决Mysql服务器启动时报错问题的方法
- android @override 报错解决方案
- 编译PHP报错configure error Cannot find libmysqlclient under usr的解决方法
- javaScript中push函数用法实例分析
- flash 报错捕获(Catch All Exception in Flash)
- Eclipse引入jquery报错如何解决
- jquery中push()的用法(数组添加元素)
- javascript在myeclipse中报错的解决方法
- Android启动模拟器报错解决方法
- 基于jni调用时,jvm报错问题的深入分析
- innerHTML在IE中报错解决方案
- Git远程操作详解
- Laravel 5框架学习之Laravel入门和新建项目
- 25个 Git 进阶技巧(翻译)