zoukankan      html  css  js  c++  java
  • 远程重命名项目分支

    Git命令可以很方便地重命名本地分支: 

    Java代码  收藏代码
    1. git branch -m <old_branch_name> <new_branch_name>  



    如果想在远程重命一个分支名,则须使用以下思路: 

    • 在本地的clone版本中重命名分支
    • 删除远程待修改的分支名
    • 则本地的新分支名push到远程



    以下是例子,首先是本地重命名: 

    Bash代码  收藏代码
    1. weli@power:~/projs/resteasy/forked$ git branch -m RESTEASY_JAXRS_1_2_1_GA_02_patch01 RESTEASY_JAXRS_1_2_1_GA_CP02_patch01  



    接下来删除远程待修改的分支名: 

    Bash代码  收藏代码
    1. weli@power:~/projs/resteasy/forked$ git push origin :RESTEASY_JAXRS_1_2_1_GA_02_patch01  
    2. To git@github.com:liweinan/Resteasy.git  
    3.  - [deleted]         RESTEASY_JAXRS_1_2_1_GA_02_patch01  



    最后将本地的新分支名push到远程: 

    Bash代码  收藏代码
    1. weli@power:~/projs/resteasy/forked$ git push origin RESTEASY_JAXRS_1_2_1_GA_CP02_patch01  
    2. Counting objects: 274, done.  
    3. Delta compression using up to 8 threads.  
    4. Compressing objects: 100% (140/140), done.  
    5. Writing objects: 100% (144/144), 12.50 KiB, done.  
    6. Total 144 (delta 69), reused 30 (delta 0)  
    7. To git@github.com:liweinan/Resteasy.git  
    8.  * [new branch]      RESTEASY_JAXRS_1_2_1_GA_CP02_patch01 -> RESTEASY_JAXRS_1_2_1_GA_CP02_patch01  


    补充:

    本地git 操作

    git branch <new_branch_name> 建立本地 local branch
    git branch -m <old_name> <new_name> 改名字 (如果有同名會失敗,改用 -M 可以強制覆蓋)
    git branch 列出目前有那些 branch 以及目前在那個 branch
    git checkout <branch_name> 切換 branch (注意到如果你有檔案修改了卻還沒 commit,會不能切換 branch,解法稍後會談)
    git checkout -b <new_branch_name> (<from_branch_name>) 本地建立 branch 並立即 checkout 切換過去
    git branch -d <branch_name> 刪除 local branch

    源自:http://ihower.tw/blog/archives/2620


    参考资料: 

    [1] http://stackoverflow.com/questions/1526794/git-rename-remote-branch 

    [2] http://ariejan.net/2010/08/09/rename-a-git-branch

  • 相关阅读:
    java中的锁
    CAS机制与自旋锁
    volatile关键字的特性及证明
    java中并发下的集合类
    数据库的分库分表
    浅入理解JVM
    99乘法表
    JAVA实现简单的时间刷新使用线程
    线程的优先级
    线程礼让
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/5290821.html
Copyright © 2011-2022 走看看