Git branch 分支

查看当前有哪些branch

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch
* master

新建一个branch xm2.x

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch xm2.x

切换到一个branch

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git checkout xm2.x

新建并且切换到该branch,例: xm2.x

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git checkout -b xm2.x

再次查看

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch
* master
xm2.x

添加一个文件到你的repo

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git add bixiaopeng.txt

添加所有的文件 git add .

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git add .

commit一个文件

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git commit -m "bixiaopeng test case"

commit到本地

bixiaopeng@bixiaopengtekiMacBook-Pro 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的区别

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ 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 xmrobotium$ git branch -r
origin/master
origin/xm2.x

查看本地和远程分支

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch -a
master
* xm2.x
remotes/origin/master
remotes/origin/xm2.x

修改branch的名字

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch -m xm2.x test2.x
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch -r
origin/master
origin/xm2.x

查看本地和远程所有的分支

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch -a
master
* test2.x
remotes/origin/master
remotes/origin/xm2.x

删除远程分支

bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ 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 xmrobotium$ git status
On branch xm3.0
nothing to commit, working directory clean
bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ 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

Git branch 分支与合并分支的更多相关文章

  1. Git 创建分支与合并分支

    下面以branchName=>aiMdTest为例介绍 1.  下载code git clone masterUrl iva(另存文件名) 2.  创建并切换分支 cd iva git chec ...

  2. 前端项目中使用git来做分支和合并分支,管理生产版本

    最近由于公司前端团队扩招,虽然小小的三四团队开发,但是也出现了好多问题.最让人揪心的是代码的管理问题:公司最近把版本控制工具从svn升级为git.前端H5组目前对git的使用还不是很熟悉,出现额多次覆 ...

  3. git branch查看不到分支的名字解决办法

    git branch查看不到分支的名字解决办法 <!-- 1. 先初始化 --> git init; <!-- 2. 接着创建瑶瑶的专属分支 --> git checkout ...

  4. svn 创建分支、切换分支 及 合并分支 操作

    关联远程仓库: 右键  ---  点击 ' SVN Checkout...' 生成 打开trunk目录,在trunk目录下新建两个文本文件A.java,B.java: 打开A.java输入以下内容: ...

  5. 二、TortoiseSVN 合并、打分支、合并分支、切换分支

    一.合并 点击Edit conflict来编辑冲突: 在合并后的枝干对应栏中编辑后,Save保存后关闭. 二.TortoiseSVN 打分支.合并分支.切换分支 1.SVN打分支 方式一:先检出,再打 ...

  6. idea实现svn拉分支和合并分支的教程

    原文地址:https://blog.csdn.net/qq_27471405/article/details/78498260 今天测试了一下svn拉分支和合并分支的教程,决定分享给大家 拉分支教程: ...

  7. Git入门指南十一:Git branch 分支与合并分支

    十五. Git branch 分支 查看当前有哪些branch bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch * master ...

  8. 10.Git分支-分支管理(git branch命令)、分支开发工作流

    1.分支管理  git branch 不仅可以创建和删除分支,还可以做一些其他工作. 1.不带参数的 git branch ,得到本地仓库当前的分支列表.并且会显示,当期所在的分支,也就是HEAD所指 ...

  9. git中如何切换分支,拉取分支,合并分支

    idea中如何使用git来做分支的切换合并: https://blog.csdn.net/autfish/article/details/52513465 本地分支与远程分支: https://seg ...

随机推荐

  1. samba速度调优

    本来windows上传到板子上的速度很慢 增加 socket options = TCP_NODELAY 明显上传下载速度都快了 参考: https://superuser.com/questions ...

  2. 栈帧 2.6. Frames 虚拟机内存模型

    https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-2.html#jvms-2.6 小结: 1. https://docs.oracle. ...

  3. JS之JSON.parse和JSON.stringify

    这两个函数有兼容性问题, 会报错JSON"未定义 解决方案, 引入json2.js,可以解决浏览器的兼容性 https://link.jianshu.com/?t=https://githu ...

  4. # 20165225 《Java程序设计》第一周学习总结

    20165225 <Java程序设计>第一周学习总结 1.视频与课本中的学习: 首先是为了运行和开发Java分别安装了JRE和JDK,具体做法在老师给的<Java2 实用教程(第五版 ...

  5. 知乎改版api接口之scrapy自动登陆

    最近使用scrapy模拟登陆知乎,发现所有接口都发生变化了,包括验证码也发生了很大变化,通过抓包分析,记录下改版后的知乎模拟登陆,废话不多说,直接上代码,亲测有效 # -*- coding: utf- ...

  6. CF718C Sasha and Array 线段树+矩阵加速

    正解:线段树 解题报告: 传送门! 首先这种斐波拉契,又到了1e9的范围,又是求和什么的,自然而然要想到矩阵加速昂 然后这里主要是考虑修改操作,ai+=x如果放到矩阵加速中是什么意思呢QAQ? 那不就 ...

  7. 【Python全栈-数据库】数据库基础

    数据库的简介 数据库 数据库(database,DB)是指长期存储在计算机内的,有组织,可共享的数据的集合.数据库中的数据按一定的数学模型组织.描述和存储,具有较小的冗余,较高的数据独立性和易扩展性, ...

  8. Eclipse设置注释模板和工作空间背景色为豆沙绿

    Eclipse Version: Photon Release (4.8.0). 首先上图,根据图上的步骤即可完成注释模板的设置. 1 如何设置eclipse注释模板的日期格式 在eclipse的 P ...

  9. eslint 在VSCode中不能使用

    在VSCode中安装号eslint插件,还是不能使用,还需安装 npm install eslint-plugin-promise --save-dev 我也不知道为什么?我现在只是用两天不到vsco ...

  10. MongoDB limit 选取 skip跳过 sort排序 方法

    MongoDB  limit 选取 skip跳过 sort排序 在mysql里有order by  MongoDB用sort代替order by > db.user.find() { " ...