zoukankan      html  css  js  c++  java
  • git 查看、创建、切换、删除、重命名和推送分支

    1、查看本地所有分支:前面有 “*” 的是当前所处的分支 

    $ git branch
      test-A
    * test-B

    2、查看本地和远程服务器的所有分支:

    $ git branch -a
      test-A
    * test-B
      remotes/origin/HEAD -> origin/test-C  // 表示远程服务器的当前分支,新clone代码会默认在此分支
      remotes/origin/test-D

    3、创建本地分支

    $ git branch test-E
    $ git branch
      test-A
    * test-B
      test-E

    4、切换本地分支

    $ git checkout test-E
    $ git branch
      test-A
      test-B
    * test-E

    5、创建并切换分支(等同于以上的 3、4)

    $ git checkout -b test-E

    6、删除本地分支

    $ git branch -D test-A
    Deleted branch test-A (was xxxxxxx).

    7、重命名本地分支

    $ git branch -m test-E test-F
    $ git branch
    * test-B
      test-F

    8、本地分支推送到远程服务器

    $ git push origin test-F:test-F

    7、删除远程分支

    $ git branch -r -d origin/test-F 
    已删除远程分支 origin/test-F(曾为 88ffe37)。
    $ git push origin :test-F
    To xxx@192.168.1.100:xxx.git
     - [deleted]         test-F

     删除远程分支后,git branch -a 还是能看到刚才删除的分支。

    $ git branch -a
    * test-B
      test-F
      remotes/origin/test-A
      remotes/origin/test-B
      remotes/origin/HEAD -> origin/test-C
      remotes/origin/test-D
      remotes/origin/test-F
    
    $ git remote show origin
      refs/remotes/origin/test-F stale (use 'git remote prune' to remove)
    
    $ git remote prune origin
    Pruning origin
    * [pruned] origin/test-F
    
    $ git branch -a
    * test-B
      test-F
      remotes/origin/test-A
      remotes/origin/test-B
      remotes/origin/HEAD -> origin/test-C
      remotes/origin/test-D
  • 相关阅读:
    开启nginx缓存
    xsl输出html代码 非闭合
    记一次网络波动导致druid连接池无法创建新连接的BUG
    mysql时间操作
    JVM知识点精华汇总
    java 基础 ---HashMap、HashTable
    java面试--小谈如何面试
    Spring框架
    JAVA+微信支付APP开发+支付宝支付APP开发
    消息队列
  • 原文地址:https://www.cnblogs.com/lialong1st/p/8032629.html
Copyright © 2011-2022 走看看