zoukankan      html  css  js  c++  java
  • Git-分支管理

    ¤ 查看本地分支: git branch

    ¤ 修改分支名称:git branch -m 原名 新名 

     

    ¤ 查看所有远程分支和本地分之: git branch -agit remote prune origin 清除branch -a的无用分支

    ¤ 创建分支: git branch test 或者 git checkout -b test 或者 git checkout -b myfeature develop (从develop分支创建一个新分支 myfeature 并切换到新分支)

    ¤ 切换分支: git checkout test

      tips:切换分支问题:如果在分支A上修改代码没有commit 你切换分支到B的时候会发现代码也被带到B分支上面了。

    ¤ 本地分支推送到远程仓库: git push origin test

    ¤ 删除分支: git branch -d test(强制删除:git branche -D test)

    ¤ 合并分支:

    步骤解释
    git checkout master 切换到主支上
    git merge dev (git merge --no-ff dev) 将dev分支合并到主支上

      tips:分支管理策略 通常情况下,合并分支 Git会使用Fast Forward模式,但是这种模式,删除分支会丢失分支信息。如果禁用Fast Forward模式,那么在merge的时候就可以看到历史分支信息 git merge --no-ff -m "merge with no-ff" testing

     ¤ 创建远程分支:

    步骤解释
    git clone git@git.oschina.net:lyjmy/gittest.git 克隆远程仓库
    git branch dev 创建dev分支
    git checkout dev 切换分支
    echo 我的第一次 > first.txt 创建一个文件
    git add first.txt 把这个文件添加到缓存
    git commit -m 'commit first.txt to dev branch' 提交
    git push origin dev 推送分支到远程,在远程就会多一个分支

     

    ¤ 删除远程分支: git push origin --delete dev

      tips:基本上这个命令做的只是从服务器上移除这个指针。 Git 服务器通常会保留数据一段时间直到垃圾回收运行,所以如果不小心删除掉了,通常是很容易恢复的。

     

    ¤ 查看各个分支当前所指的对象(查看提交记录) git log --oneline --decorate

    ¤ 查看每个分支最后一次提交 git branch -v

    ¤ 查看哪些分支已经合并到当前分支 git branch --merged

    ¤ 查看哪些分支未合并到当前分支 git branch --no-merged

    ¤ 存储工作现场 git stash

    ¤ 查看工作现场 git stash list

    ¤ 恢复工作现场 git stash apply

    ¤ 恢复工作现场同时把stash内容也删了 git stash pop

    参考:

    【1】,https://git-scm.com/book/zh/v2

    【2】,博客,https://blog.zengrong.net/post/1746.html

  • 相关阅读:
    java多线程设计模式
    Java横向、纵向合并图片
    Oracle数据库当前连接数、最大连接数的查询与设置
    oracle获取一段时间内所有的小时、天、月
    Struts2+Spring3+Mybatis3开发环境搭建
    Spring3.3 整合 Hibernate3、MyBatis3.2 配置多数据源/动态切换数据源方法
    spring+mybatis 多数据源切换
    Java与WCF交互(一):Java客户端调用WCF服务
    使用axis2进行WebService的开发
    axis2 WebService的发布与调用
  • 原文地址:https://www.cnblogs.com/happyflyingpig/p/8869432.html
Copyright © 2011-2022 走看看