GIT学习----第十四节:BUG分支

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_38082783/article/details/84645298

学习目的

  1. 遇到临时bug需要紧急修复,在git如何处理?
  2. git如何进行工作区进行储藏,等待bug修复后的工作区恢复?

临时储藏

  1. 修改后查看工作区状态
$ git status
On branch master
Your branch is ahead of 'origin/master' by 10 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:   readme.txt

no changes added to commit (use "git add" and/or "git commit -a")
  1. 临时存储git stash
$ git stash
Saved working directory and index state WIP on master: 118be5d --no-ff模式合并
  1. 查看工作区
$ git status
On branch master
Your branch is ahead of 'origin/master' by 10 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
  1. 新建bug分支’issue-001’
$ git checkout -b issue-001
Switched to a new branch 'issue-001'
  1. 修改文件查看,添加’bug分支测试!’
$ cat readme.txt
Git is a version control system.
Git is free software.
Git is a distributed version control system.
Git is free software.
添加一行测试工作区、暂存区、分支。
cat 命令测试。
测试修改文件后各区状态!
测试git diff,查看工作区和分支文件的修改情况!
再次测试git diff对比工作区和版本库最新版本的区别。
测试撤销修改!
Creating a new branch is quick and simple.
测试分支合并冲突!

分支管理测试!

测试fast forward合并模式!

测试--no-ff合并模式!

bug分支测试!
  1. bug分支提交
$ git add readme.txt

$ git commit -m "bug分支测试提交"
[issue-001 991a531] bug分支测试提交
 1 file changed, 3 insertions(+), 1 deletion(-)
  1. 切换到master分支,合并issue-001分支,删除issue-001分支
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 10 commits.
  (use "git push" to publish your local commits)


$ git merge --no-ff -m "bug分支测试合并" issue-001
Merge made by the 'recursive' strategy.
 readme.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


$ git branch -d issue-001
Deleted branch issue-001 (was 991a531).
  1. 查看工作区,查看现场储藏区,恢复储藏文件,再查看工作区
查看工作区
$ git status
On branch master
Your branch is ahead of 'origin/master' by 12 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

查看现场储藏区
$ git stash list
stash@{0}: WIP on master: 118be5d --no-ff模式合并

恢复储藏文件
$ git stash pop
Auto-merging readme.txt
CONFLICT (content): Merge conflict in readme.txt

再查看工作区
$ git status
On branch master
Your branch is ahead of 'origin/master' by 12 commits.
  (use "git push" to publish your local commits)

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   readme.txt

no changes added to commit (use "git add" and/or "git commit -a")

总结

  1. 正在工作区工作,突然进行紧急bug修复,储藏现场git stash;
  2. 新建bug分支,进行修复bug,提交修复,切换到master,合并bug分支,删除bug分支。
  3. 恢复工作区git stash pop(简写命令)。查看储藏列表git stash list;恢复储藏git stash apply;删除储藏git stash drop。

其他

QQ交流群: 264303060

QQ交流群

我的博客,欢迎交流!

我的CSDN博客,欢迎交流!

微信小程序专栏

前端笔记专栏

微信小程序实现部分高德地图功能的DEMO下载

微信小程序实现MUI的部分效果的DEMO下载

微信小程序实现MUI的GIT项目地址

微信小程序实例列表

前端笔记列表

游戏列表

猜你喜欢

转载自blog.csdn.net/m0_38082783/article/details/84645298