1、查看分支:
git branch
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git branch
* master
2、创建分支:
git branch devlopment
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git branch devlopment
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git branch
devlopment
* master
3、切换分支:
git checkout {分支名}
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git checkout devlopment
Switched to branch 'devlopment'
新建分支修改不影响主干:
admin@jimmy MINGW64 /e/Desktop/dbhost (devlopment)
$ git status
On branch devlopment
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
admin@jimmy MINGW64 /e/Desktop/dbhost (devlopment)
$ git add .
admin@jimmy MINGW64 /e/Desktop/dbhost (devlopment)
$ git commit -m 分支开发
[devlopment 8650f07] 分支开发
1 file changed, 1 insertion(+), 1 deletion(-)
4、将分支合并为主干:
(1)先切换回主干:
git checkout master
admin@jimmy MINGW64 /e/Desktop/dbhost (devlopment)
$ git checkout master
Switched to branch 'master'
(2)合并分支:
git merge {分支名}
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git merge devlopment
Updating dbaffde..8650f07
Fast-forward
readme.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(3)(谨慎使用删除) 合并后,删除分支:
git branch -d {分支名}
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git branch -d devlopment
Deleted branch devlopment (was 8650f07).
admin@jimmy MINGW64 /e/Desktop/dbhost (master)
$ git branch
* master