新建提交

代码片段
7 行
cd
git init
git add .
git add README.md
git commit -m "iswtf"
git remote add origin https://github.com/dubaiyouyue/iswtf.git
git push -u origin master

Gitshell登录

代码片段
2 行
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

常用命令

Git 常用命令图

分支/Tag版本管理

本地的分支管理
创建分支

代码片段
1 行
git branch dev

创建后会自动切换到新创建的分支

代码片段
1 行
git checkout -b dev

切回master分支

代码片段
1 行
git checkout master

合并

代码片段
2 行
git checkout master   // 切换到master
git merge debug       // 合并debug到master 
代码片段
1 行
$git push origin test:master         // 提交本地test分支作为远程的master分支
代码片段
5 行
git pull <远程主机名> <远程分支名>:<本地分支名>
git pull origin xf:xf

git push <远程主机名> <本地分支名>:<远程分支名>
git push origin xf:xf

fetch更新本地仓库两种方式

代码片段
10 行
//方法一
$ git fetch origin master //从远程的origin仓库的master分支下载代码到本地的origin master
$ git log -p master.. origin/master//比较本地的仓库和远程参考的区别
$ git merge origin/master//把远程下载下来的代码合并到本地仓库,远程的和本地的合并

//方法二
$ git fetch origin master:temp //从远程的origin仓库的master分支下载到本地并新建一个分支temp
$ git diff temp//比较master分支和temp分支的不同
$ git merge temp//合并temp分支到master分支
$ git branch -d temp//删除temp
代码片段
1 行
$ git clone http://github.com/jquery/jquery.git

远程分支管理

代码片段
1 行
git push -u origin master

创建远程的dev分支到本地

代码片段
1 行
git checkout -b dev origin/dev 

本地Tag管理

代码片段
1 行
git tag -a v1.0 -m "第一个里程碑的突破"

查看标签

代码片段
1 行
git tag 

远程Tag管理
推送到远程

代码片段
1 行
git push origin v1.0

所有的标签一次推送到远程

代码片段
1 行
git push origin --tags

删除标签
本地

代码片段
1 行
git tag -d v1.0

远程

代码片段
1 行
git push origin :refs/tags/v1.0