5、Git本地分支与合并
2016-05-24 17:34
531 查看
1、git branch
创建分支 git branch test
切换分支 git checkout test
在test分支上修改不会影响master的内容;
2、git tag
songyanchengdeMacBook-Pro:Jax_git Jax$ git log --oneline --decorate --graph --all
* 813ee49 (test) commit on test
* 681651a (HEAD -> master) 2 commit on master
* 31a1b55 modify a
* fb81826 init commit
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag "TagName" fb81826
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag -a "INITAL_COMMIT" fb81826
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag
INITAL_COMMIT
TagName
songyanchengdeMacBook-Pro:Jax_git Jax$ git log --oneline --decorate --graph --all
* 813ee49 (test) commit on test
* 681651a (HEAD -> master) 2 commit on master
* 31a1b55 modify a
* fb81826 (tag: TagName, tag: INITAL_COMMIT) init commit
3、git checkout
4、git status
git stash save -a "stash1"(保存当前的记录)
git stash apply [--index [stashName]]
git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。
git stash pop [--index [stashName]]: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。
git stash drop [stashName] 清理某个节点。
当前工作区内容已被修改,但是并未完成。这时Boss来了,说前面的分支上面有一个Bug,需要立即修复。可是我又不想提交目前的修改,因为修改没有完成。但是,不提交的话,又没有办法checkout到前面的分支。此时用Git Stash就相当于备份工作区了。然后在Checkout过去修改,就能够达到保存当前工作区,并及时恢复的作用。
5、git merge
git merge BranchName
git merge --abort 取消合并
创建分支 git branch test
切换分支 git checkout test
在test分支上修改不会影响master的内容;
2、git tag
songyanchengdeMacBook-Pro:Jax_git Jax$ git log --oneline --decorate --graph --all
* 813ee49 (test) commit on test
* 681651a (HEAD -> master) 2 commit on master
* 31a1b55 modify a
* fb81826 init commit
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag "TagName" fb81826
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag -a "INITAL_COMMIT" fb81826
songyanchengdeMacBook-Pro:Jax_git Jax$ git tag
INITAL_COMMIT
TagName
songyanchengdeMacBook-Pro:Jax_git Jax$ git log --oneline --decorate --graph --all
* 813ee49 (test) commit on test
* 681651a (HEAD -> master) 2 commit on master
* 31a1b55 modify a
* fb81826 (tag: TagName, tag: INITAL_COMMIT) init commit
songyanchengdeMacBook-Pro:Jax_git Jax$ git show TagName commit fb818262e1d3548034f2417aa286ffaaef7bb932 Author: Jax <Jax@songyanchengdeMacBook-Pro.local> Date: Tue May 24 16:05:43 2016 +0800 init commit diff --git a/a b/a new file mode 100644 index 0000000..e69de29 diff --git a/b b/b new file mode 100644 index 0000000..e69de29切换到Tag并创建分支
songyanchengdeMacBook-Pro:Jax_git Jax$ git checkout -b fix_TagName Switched to a new branch 'fix_TagName'
3、git checkout
4、git status
git stash save -a "stash1"(保存当前的记录)
git stash apply [--index [stashName]]
git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。
git stash pop [--index [stashName]]: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。
git stash drop [stashName] 清理某个节点。
当前工作区内容已被修改,但是并未完成。这时Boss来了,说前面的分支上面有一个Bug,需要立即修复。可是我又不想提交目前的修改,因为修改没有完成。但是,不提交的话,又没有办法checkout到前面的分支。此时用Git Stash就相当于备份工作区了。然后在Checkout过去修改,就能够达到保存当前工作区,并及时恢复的作用。
5、git merge
git merge BranchName
git merge --abort 取消合并
相关文章推荐
- struts2的工作原理
- 前端跨域的整理
- PHP中XML和数组互相转换的方法
- windows-64位环境下搭建PHP5.5+Apache2.4+Mysql5.6+PhpMyAdmin
- android eclipse中html编辑器插件的下载和安装
- PHP中XML和数组互相转换的方法
- 创建响应式布局-图片、自适应与响应式
- 在$scope中变量和方法的使用
- 处理Xcode 警告
- Struts2的类型转换器
- Nginx Upstream负责均衡的实现方案
- 数据库之SQL的主键和外键的作用
- 集合框架-泛型
- itext导出word文档常用方法汇总
- JSOI2016酱油记
- Linux下的find指令详解
- Spring MVC详细运行流程
- js快速排序
- php mysql支持emoji表情方案
- android—sdk遇到的问题- Support Libraries删除后找不到