git分支合并

本文是从master分支拉出的two,然后合并回master
 
1、切换到master分支:
git checkout master
2、创建并切换到two分支:
git checkout -b two
这相当于
git branch two
git checkout two

3、将two分支push到远程仓库(与本地仓库同步):

git push origin two

4、修改two分支上的内容并提交到本地仓库:

git commit -a -m"修改子分支"

5、将two分支上的修改提交到远程仓库:

git push origin two

6、two分支上的修改ok后,切换到master分支:

git checkout master(注意,只有checkout切换到当前分支后,pull代码,才能看见当前分支的代码,如果没有checkout到当前分支,pull了也在相应文件夹下也看不见当前分支的代码,而是上次checkout的代码)

7、将two分支合并到master分支:

      先切回到master分支上 

git checkout master
git merge origin two(要确保分支和主分支的数据是一样的:可以切换分支然后在two分支上进行操作 git pull origin master,如果有更新下来东西,要git push origin two 到two分支上)

8、将合并之后的代码push到远程仓库:

git push origin master

 此例是父分支和自分支之间的merge操作,爷孙分支亦如此,旁系分支合并亦然

posted @ 2019-09-01 18:46  学习everyday  阅读(630)  评论(0编辑  收藏  举报