[root@controller161 gitdemo]# git statusOn branch master
You have unmerged paths.
(fix conflicts and run "git commit")Unmerged paths:
(use "git add <file>..." to mark resolution) both modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
打开readme.txt,内容变成这样:
1
2
3
4
5
6
7
8
9
<<<<<<< HEAD
hello git master
=======
hello git, feature1
>>>>>>> feature1
I like git very much
add something
这次加一行啦啦啦
this is dev line
[root@controller161 gitdemo]# vim readme.txt[root@controller161 gitdemo]# git branch* dev
master
[root@controller161 gitdemo]# git statusOn branch dev
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")
[root@controller161 gitdemo]# git stashSaved working directory and index state WIP on dev: a2c9e32 fix confict
HEAD is now at a2c9e32 fix confict
可以放心地创建分支来修复bug,假定需要在master分支上修复,就从master创建临时分支:
1
2
3
4
[root@controller161 gitdemo]# git checkout masterSwitched to branch 'master'[root@controller161 gitdemo]# git checkout -b issue-101Switched to a new branch 'issue-101'
现在修复bug,readme.txt修改为:
1
2
3
4
5
hello git master and feature1
I like git very much
add something, fix bug101
这次加一行啦啦啦
this is dev line
[root@controller161 gitdemo]# git merge --no-ff -m "merged bug fix 101" issue-101Merge made by the 'recursive' strategy.
readme.txt |2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
改完bug,是时候接着回到dev分支干活了:
1
2
3
4
5
[root@controller161 gitdemo]# git checkout devSwitched to branch 'dev'[root@controller161 gitdemo]# git statusOn branch dev
nothing to commit, working directory clean
[root@controller161 gitdemo]# git stash popOn branch dev
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")Dropped refs/stash@{0}(2df611a386511cc7989db79457b620b9971c08b5)