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

最新文章

  1. mongodb安装、启动、远程连接
  2. iOS 视图:重绘与UIScrollView(内容根据iOS编程编写)
  3. Android中 int,float,Double,String 互相转换
  4. 将file转变成contenthash
  5. 解决连接Oracle 11g报ORA-01034和ORA-27101的错误
  6. Git版本管理:Windows下Git配置与使用指南
  7. oracle 分区表和分区索引
  8. hdoj 2802 F(N)【递推 规律】
  9. MongoDB_1
  10. js问题学习
  11. SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法
  12. 浅谈h5移动端页面的适配问题
  13. viewpager+layout布局文件随数据多少创建滑动页面
  14. NPOI office 组件资料汇总 (excel, word)
  15. input框内的单引号,双引号转译
  16. 关于tomcat7配置maxPostSize=“0”时,后台无法接收前台参数的问题
  17. Troubleshooting SQL Server RESOURCE_SEMAPHORE Waittype Memory Issues
  18. LeetCode 258 Add Digits 解题报告
  19. 字体图标Font Awesome 的使用
  20. 【Python】多进程-4

热门文章

  1. windows共享文件分析
  2. [others] 一个酷酷的站
  3. H2O 笔记之安装
  4. EF-CodeFirst-数据迁移
  5. 洛谷P3248 树 [HNOI2016] 主席树+倍增+分治
  6. 【Python全栈-后端开发】Django入门基础
  7. JavaScript 数组(Array)对象
  8. SmokePing介绍
  9. springmvc拦截器实现用户登录权限验证
  10. 对集合类的属性进行kvo观察