我建议:
- 提交您的单元测试专用,临时党支部,
- 回复的bug修复在这个分支,
- 测试你的单元测试,
- 如果一切OK,重订/在主合并的单元测试
演示:
# INIT
$ git init test
Initialized empty Git repository in /tmp/test/.git/
$ cd test/
$ echo bug > file
$ git add file
$ git commit -m"Commit with bugs in it"
[master (root-commit) 498680f] Commit with bugs in it
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file
$ echo feature > file
$ git commit -am"Fix bug #1"
[master 05540d3] Fix bug #1
1 files changed, 1 insertions(+), 1 deletions(-)
# (1)
$ echo 42 > unit-test
$ git add unit-test
$ git checkout -b unit-test
A unit-test
Switched to a new branch 'unit-test'
$ git commit -m"Add unit test for bug #1"
[unit-test 240bc6c] Add unit test for bug #1
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 unit-test
$ git l
* 240bc6c (HEAD, unit-test) Add unit test for bug #1
* 05540d3 (master) Fix bug #1
* 498680f Commit with bugs in it
# (2)
$ git revert 05540d3
Finished one revert.
[unit-test 5f5eb62] Revert "Fix bug #1"
1 files changed, 1 insertions(+), 1 deletions(-)
$ git l
* 5f5eb62 (HEAD, unit-test) Revert "Fix bug #1"
* 240bc6c Add unit test for bug #1
* 05540d3 (master) Fix bug #1
* 498680f Commit with bugs in it
# (3)
$ # check for bug
# (4)
$ git checkout master
Switched to branch 'master'
$ git rebase 240bc6c
First, rewinding head to replay your work on top of it...
Fast-forwarded master to 240bc6c.
$ git branch -D unit-test
Deleted branch unit-test (was 5f5eb62).
$ git l
* 240bc6c (HEAD, master) Add unit test for bug #1
* 05540d3 Fix bug #1
* 498680f Commit with bugs in it
来源
2016-02-19 15:10:48
YSC
构建完成后复制(不复制)您的repo文件夹,然后随副本一起玩。即使你搞砸了,你也有原始的完整。 –