bug分支和feature分支.pdfVIP

  • 3
  • 0
  • 约4.16千字
  • 约 5页
  • 2017-08-22 发布于河北
  • 举报
bug分支和feature分支.pdf

bug 分支和 feature 分支 软件开发中,bug 就像家常便饭一样。有了bug 就需要修复,在Git 中,由于分支是如此的强大,所以,每个bug 都可 以通过一个新的临时分支来修复,修复后,合并分支,然后将临时分支删除。 当你接到一个修复一个代号101 的bug 的任务时,很自然地,你想创建一个分支issue-101 来修复它,但是,等等,当前 正在dev 上进行的工作还没有提交: $ git status # On branch dev # Changes to be committed: # (use git reset HEAD file... to unstage) # # new file: hello.py # # 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 # 并不是你不想提交,而是工作只进行到一半,还没法提交,预计完成还需1 天时间。但是,必须在两个小时内修复该bug, 怎么办? 幸好,Git 还提供了一个 stash 功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作: $ git stash Saved working directory and index state WIP on dev: 6224937 add merge HEAD is now at 6224937 add merge 现在,用git status 查看工作区,就是干净的(除非有没有被Git 管理的文件),因此可以放心地创建分支来修复bug。 首先确定要在哪个分支上修复bug,假定需要在master 分支上修复,就从master 创建临时分支: 1 / 5 $ git checkout master Switched to branch master Your branch is ahead of origin/master by 6 commits. $ git checkout -b issue-101 Switched to a new branch issue-101 现在修复bug,需要把“Git is free software ...”改为“Git is a free software ...”,然后提交: $ git add readme.txt $ git commit -m fix bug 101 [issue-101 cc17032] fix bug 101 1 file changed, 1 insertion(+), 1 deletion(-) 修复完成后,切换到master 分支,并完成合并,最后删除 issue-101 分支: $ git checkout master Switched to branch master Your branch is ahead of origin/master by 2 commits. $ git merge --no-ff -m merged bug fix 101 issue-101 Merge made by the recursive strategy. readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) $ git branch -d issue-101 Deleted branch issue-101 (was cc17032). 太棒了,原计划两个小时的bug 修复只花了5 分钟!现在,是时候接着回到dev 分支干活了! $ git checkout dev Switched to branch dev $ git status # On branch dev 2 / 5 nothing to commit (working directory clean) 工

文档评论(0)

1亿VIP精品文档

相关文档