源码管理十四:bug分支
来源:互联网 发布:先锋软件下载 编辑:程序博客网 时间:2024/05/22 13:44
在实际开发中,可能会碰到这样一种情况:
此时我正在dev分支进行开发工作,突然接到通知必须在两个小时内修复一个重大Bug,并且我此时手头的工作还没有提交,并不是我不想提交,而是工作只进行到一半,还没法提交,可能还需要13个小时才可以完成,该怎么办?
zhanggeng:git_learning (master *)$git statusOn branch masterYour branch is ahead of 'origin/master' by 6 commits. (use "git push" to publish your local commits)Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)modified: hello.txtno changes added to commit (use "git add" and/or "git commit -a")
不要担心,万能的Git为我们提供了一个stash
功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作:
zhanggeng:git_learning (master *)$git stashSaved working directory and index state WIP on master: a58efef merge with no-ffHEAD is now at a58efef merge with no-ff
这个时候,再次查看工作区的时候,就会发现,工作区是干净的。
zhanggeng:git_learning (master)$git statusOn branch masterYour branch is ahead of 'origin/master' by 6 commits. (use "git push" to publish your local commits)nothing to commit, working directory clean
现在开始修复Bug,首先得确定Bug在的位置,假如是在master分支上,那么就在master分支上创建临时分支:
zhanggeng:git_learning (master)$git checkout -b issue-01Switched to a new branch 'issue-01'现在,在分支 issue-01 上劳动,修复bug,修复完成后,提交。
zhanggeng:git_learning (issue-01)$vim hello.txt zhanggeng:git_learning (issue-01 *)$git add hello.txtzhanggeng:git_learning (issue-01 +)$git commit -m "fix bug 01"[issue-01 dbe139a] fix bug 01 1 file changed, 1 insertion(+)再切换到master分支上,进行合并,合并完成后删除bug分支。
zhanggeng:git_learning (issue-01)$git checkout masterSwitched to branch 'master'Your branch is ahead of 'origin/master' by 6 commits. (use "git push" to publish your local commits)zhanggeng:git_learning (master)$git merge --no-ff -m "merged bug fix 01" issue-01Merge made by the 'recursive' strategy. hello.txt | 1 + 1 file changed, 1 insertion(+)完成上述操作后,可以切换到dev分支上继续劳动:
zhanggeng:git_learning (master)$git checkout devSwitched to branch 'dev'zhanggeng:git_learning (dev)$git statusOn branch devnothing to commit, working directory clean
工作区是干净的,刚才的工作现场存到哪去了?用git stash list
命令看看:
zhanggeng:git_learning (dev)$git stash liststash@{0}: WIP on master: a58efef merge with no-ff工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法:
一是用git stash apply
恢复,但是恢复后,stash内容并不删除,你需要用git stash drop
来删除;
另一种方式是用git stash pop
,恢复的同时把stash内容也删了:
zhanggeng:git_learning (dev)$git stash popOn branch devChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)modified: hello.txtno changes added to commit (use "git add" and/or "git commit -a")Dropped refs/stash@{0} (dedf30b9bc4bd539277d92a8c5d8290d2cd15812)再用
git stash list
查看,就看不到stash内容了:zhanggeng:git_learning (dev *)$git stash listzhanggeng:git_learning (dev *)$zhanggeng:git_learning (dev *)$
总之,在项目中修复bug的时候:
修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除;
当手头工作没有完成时,先把工作现场git stash
一下,然后去修复bug,修复后,再git stash pop
,回到工作现场。
0 0
- 源码管理十四:bug分支
- 分支管理---Bug分支
- git分支管理之Bug分支
- Git的bug分支管理
- 源码管理十三:分支管理策略
- OpenFire源码学习之十四:插件管理
- Bug分支
- Bug分支
- Bug分支
- Bug分支
- Bug分支
- Bug分支
- [SCM]源码管理 - perforce 分支的锁定
- 源码管理十一:创建&&合并&&删除 分支
- Git的使用十四(Bug分支)仅限Mac亲测
- Git学习系列(七)Bug和Feature分支管理详解
- 分支管理---Feature分支
- 分支管理
- hdu 2844 Coins
- 学习PHP的过程记录(4)-常用标签3
- Uva 201 Squares
- ZOJ 1409 Communication System
- ADB介绍
- 源码管理十四:bug分支
- Windows 64位下 PostgreSQL的编译
- UIScrollView详解
- S3C2440裸机实战 之一 创建初始工程
- 复用类
- jvm 参数调优
- Android使用lint检查工程中的无用资源
- GitHub上的十一款热门开源安全工具
- 为什么 parseInt(0.0000008) === 8?