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
  • 相关阅读:
    truncate删除一个分区,测试全局索引是否失效
    DG环境恢复同步遇到报错ORA-00353ORA-00334以及ORA-00600[2619], [47745]
    继承
    智能指针unique_ptr
    explicit
    编译安装python3
    Linux读写执行权限(-r、-w、-x)的真正含义
    nginx入门之编译安装
    vim
    1.yum下载 mysql及授权
  • 原文地址:https://www.cnblogs.com/lialong1st/p/8032629.html
Copyright © 2011-2022 走看看