
安装git
安装之后切记配置环境变量
码云使用
在码云上创建项目

注:.gitignore这里添加之后在上传的时候会出现eror,所以我未创建
创建 git 仓库
在工程目录空白处右键唤出git bash界面
Git全局设置
$ git config --global user.name "user.name"//这里的用户名不是昵称,其为http://git.oschina.net/xxxx/Test中的xxxx$ git config --global user.email "user.email"//如果已经设定过则可以跳过这步$ git init//初始化一个git仓库$ touch README.md//创建帮助文档,在上一步创建之后这一步可以不创建$ git add -A//添加所有文件$ git commit -m“注释内容” //添加注释$ git remote add origin https://git.oschina.net/username/xxx.git(你的远程仓库地址,即是码云的项目地址)$ git pull origin master若出现fatal: refusing to merge unrelated histories错误
参见http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories
git pull origin branchname –allow-unrelated-histories
$ git push -u origin master//上传仓库到码云
已有项目上传
- 切换至项目目录
- 在工程目录空白处右键唤出git bash界面
$ git remote add origin https://git.oschina.net/username/xxx.git$ git push -u origin master
记录每次更新到仓库
$ git status//更改文件后,可用该命令确定哪些文件当前处于什么状态$ git add 未添加文件//跟踪新文件
创建分支
$ git checkout -b branchnameSwitched to a new branch 'branchname'该命令相当于执行
$ git branch branchname$ git checkout branchname$ git checkout branchname//切换分支$ git merge branchname//融合分支$ git branch -d branchname//删除以融合分支
参考链接