关闭

Git branch 分支与合并分支

249人阅读 评论(0) 收藏 举报

十五. Git branch 分支
查看当前有哪些branch
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitbranchmasterbranchxm2.xbixiaopeng@bixiaopengtekiMacBookProxmrobotium git branch xm2.x
切换到一个branch
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitcheckoutxm2.xbranch,:xm2.xbixiaopeng@bixiaopengtekiMacBookProxmrobotium git checkout -b xm2.x
再次查看
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitbranchmasterxm2.xrepobixiaopeng@bixiaopengtekiMacBookProxmrobotium git add bixiaopeng.txt
添加所有的文件 git add .
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitadd.commitbixiaopeng@bixiaopengtekiMacBookProxmrobotium git commit -m “bixiaopeng test case”
commit到本地
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitcommitamxm2.xtestcase[xm2.xf78f430]xm2.xtestcase39fileschanged,384insertions(+)createmode100644AndroidManifest.xml.commitbixiaopeng@bixiaopengtekiMacBookProxmrobotium git diff
将branch push到远程
bixiaopeng@bixiaopengtekiMacBook-Pro 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 git@mirror.gitlab.*.com:/home/git/repositories/xiaopeng.bxp/xmrobotium.git
remote: * [new branch] xm2.x -> xm2.x
To git@gitlab.**.com:xiaopeng.bxp/xmrobotium.git
* [new branch] xm2.x -> xm2.x
查看远程分支
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitbranchrorigin/masterorigin/xm2.xbixiaopeng@bixiaopengtekiMacBookProxmrobotium git branch -a
master
* xm2.x
remotes/origin/master
remotes/origin/xm2.x
修改branch的名字
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitbranchmxm2.xtest2.xbixiaopeng@bixiaopengtekiMacBookProxmrobotium git branch -r
origin/master
origin/xm2.x
查看本地和远程所有的分支
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitbranchamastertest2.xremotes/origin/masterremotes/origin/xm2.xbixiaopeng@bixiaopengtekiMacBookProxmrobotium git push origin –delete xm2.x
remote: To git@mirror.gitlab.**.com:/home/git/repositories/xiaopeng.bxp/xmrobotium.git
remote: - [deleted] xm2.x
To git@gitlab.*.com:xiaopeng.bxp/xmrobotium.git
- [deleted] xm2.x
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch -r
origin/master
origin/test2.x
十六. Git 合并分支
首先切换到想要合并到的分枝下,运行’git merge’命令 (例如本例中将test2.x分支合并到xm3.0分支的话,进入xm3.0分支运行git merge test2.x命令)如果合并顺利的话:

确保当前分支为xm3.0
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotiumgitstatusOnbranchxm3.0nothingtocommit,workingdirectorycleanbixiaopeng@bixiaopengtekiMacBookProxmrobotium git branch
master
test2.x
* xm3.0
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git merge test2.x
Already up-to-date.
合并冲突处理:
Automatic merge failed; fix conflicts and then commit the result.

修改冲突的文件后,git add 文件 然后,git commit

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:33337次
    • 积分:906
    • 等级:
    • 排名:千里之外
    • 原创:53篇
    • 转载:20篇
    • 译文:5篇
    • 评论:3条