继上次分享之后,本次主要介绍新分支的创建、切换及合并操作。
五、创建新分支,并推送到远程仓库
1.进入本地仓库,查看当前分支:
cd git/test
git branch

2.从master分支上创建新分支并切换到该分支:git checkout -b develop

3. 不放心的话可以用git branch查看一下:

4.将develop分支推送到远程仓库:git push origin develop

完成后,检查一下github端:

5.在本地新建文件file2,并添加到本地仓库:
touch file2
git add file2
git commit -m "add file2"


6.推送到远程develop分支:git push origin develop

完成后,检查一下github端:

六、合并master分支到develop分支
1.首先我们在master分支上新建一个文件file3,模拟已经上线的代码:
git checkout master
touch file3
git add file3
git commit -m "add new file3"
git status
git push origin master:master


完成后,检查一下github端:

2.然后将本地master代码合并到develop分支:
git checkout develop
git merge master

3.合并完成后推送到远程仓库
git push origin develop

七、合并develop分支到master分支
1.首先我们在develop分支上新建一个文件file4,模拟已经提交的新功能代码:
git checkout develop
touch file4
git add file4
git commit -m“add new file4”
git status


2.将本地develop分支合并到master分支:
git checkout master
git merge develop

3.推送本地分支到远程分支:git push origin master:master

4.完成后,检查一下github端:
