怎么将master合并到branch
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了怎么将master合并到branch相关的知识,希望对你有一定的参考价值。
参考技术A This workflow works best for me:git checkout -b develop
...make some changes...
...notice master has been updated...
...commit changes to develop...
git checkout master
git pull
...bring those changes back into develop...
git checkout develop
git rebase master
...make some more changes...
...commit them to develop...
...merge them into master...
git checkout master
git pull
git merge develop
Git branch 分支与合并分支(转)
查看当前有哪些branch
[email protected] xmrobotium$ git branch
* master
新建一个branch xm2.x
[email protected] xmrobotium$ git branch xm2.x
切换到一个branch
[email protected] xmrobotium$ git checkout xm2.x
新建并且切换到该branch,例: xm2.x
[email protected] xmrobotium$ git checkout -b xm2.x
再次查看
[email protected] xmrobotium$ git branch
* master
xm2.x
添加一个文件到你的repo
[email protected] xmrobotium$ git add bixiaopeng.txt
添加所有的文件 git add .
[email protected] xmrobotium$ git add .
commit一个文件
[email protected] xmrobotium$ git commit -m "bixiaopeng test case"
commit到本地
[email protected] xmrobotium$ git commit -a -m "xm2.x test case"
[xm2.x f78f430] xm2.x test case
39 files changed, 384 insertions(+)
create mode 100644 AndroidManifest.xml
………….
查看几次commit的区别
[email protected] xmrobotium$ git diff
将branch push到远程
[email protected] xmrobotium$ git push origin xm2.x
Counting objects: 78, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (77/77), 565.97 KiB, done.
Total 77 (delta 3), reused 0 (delta 0)
remote: To [email protected]*****.com:/home/git/repositories/xiaopeng.bxp/xmrobotium.git
remote: * [new branch] xm2.x -> xm2.x
To [email protected]****.com:xiaopeng.bxp/xmrobotium.git
* [new branch] xm2.x -> xm2.x
查看远程分支
[email protected] xmrobotium$ git branch -r
origin/master
origin/xm2.x
查看本地和远程分支
[email protected] xmrobotium$ git branch -a
master
* xm2.x
remotes/origin/master
remotes/origin/xm2.x
修改branch的名字
[email protected] xmrobotium$ git branch -m xm2.x test2.x
[email protected] xmrobotium$ git branch -r
origin/master
origin/xm2.x
查看本地和远程所有的分支
[email protected] xmrobotium$ git branch -a
master
* test2.x
remotes/origin/master
remotes/origin/xm2.x
删除远程分支
[email protected] xmrobotium$ git push origin --delete xm2.x
remote: To [email protected]****.com:/home/git/repositories/xiaopeng.bxp/xmrobotium.git
remote: - [deleted] xm2.x
To [email protected]*****.com:xiaopeng.bxp/xmrobotium.git
- [deleted] xm2.x
[email protected] xmrobotium$ git branch -r
origin/master
origin/test2.x
十六. Git 合并分支
首先切换到想要合并到的分枝下,运行‘Git merge’命令 (例如本例中将test2.x分支合并到xm3.0分支的话,进入xm3.0分支运行git merge test2.x命令)如果合并顺利的话:
确保当前分支为xm3.0
[email protected] xmrobotium$ git status
On branch xm3.0
nothing to commit, working directory clean
[email protected] xmrobotium$ git branch
master
test2.x
* xm3.0
[email protected] xmrobotium$ git merge test2.x
Already up-to-date.
合并冲突处理:
Automatic merge failed; fix conflicts and then commit the result.
修改冲突的文件后,git add 文件 然后,git commit
以上是关于怎么将master合并到branch的主要内容,如果未能解决你的问题,请参考以下文章
git 开发测试分支失误合并到了master分支,怎么还原?