最近学习的git,如何修改bug
此时有两个分支:master,dev
root@gao:~/learngit# git branch
* dev
master
root@gao:~/learngit# git status .
On 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.md
root@gao:~/learngit# git stash
Saved working directory and index state WIP on dev: a70f8a2 fix confict
HEAD is now at a70f8a2 fix confict
切换到master分支
root@gao:~/learngit# git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 12 commits.
(use "git push" to publish your local commits)
创建分支issue-101
root@gao:~/learngit# git checkout -b issue-101
Switched to a new branch 'issue-101'
此时在issue-101分支
root@gao:~/learngit# git branch
dev
* issue-101
master
现在修复bug,需要把“Git is free software ...”改为“Git is a free software ...”,然后提交:
root@gao:~/learngit# git add README.md
root@gao:~/learngit# git commit -m "fix bug 101"
[issue-101 5688f23] fix bug 101
1 file changed, 1 insertion(+)
切换master分支
root@gao:~/learngit# git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 12 commits.
(use "git push" to publish your local commits)
root@gao:~/learngit# git merge --no-ff -m "merged bug fix 101" issue-101
Merge made by the 'recursive' strategy.
README.md | 1 +
1 file changed, 1 insertion(+)
删除分支dev
git branch -d issue-101
接着回到dev分支干活了
切换到dev分支
root@gao:~/learngit# git checkout dev
Switched to branch 'dev'
root@gao:~/learngit# git stash list
stash@{0}: WIP on dev: a70f8a2 fix confict
stash@{1}: WIP on master: 281a585 modify Readme.md
root@gao:~/learngit# git stash pop
On 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.md