zoukankan      html  css  js  c++  java
  • git branch

    Git push branch from one remote to another?

    A quick test making some temporary repositories shows you can construct a refspec that can do this:

    $ git push rorg origin/one:refs/heads/one
    Counting objects: 5, done.
    Writing objects: 100% (3/3), 240 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    To /tmp/rorg
     * [new branch]      origin/one -> one
    

    So origin/BRANCHNAME:refs/heads/BRANCHNAME

    Checking in my rorg remote:

    • Clone一个本地干净的库 或者 使用你本地的一个库
    • 命令行新增一个remote 叫azure
      • git remote add azure url
    • 将remote/origin中的所有分支全部推到azure中
      • git push azure refs/remotes/origin/*:refs/heads/*   //make sure the previous remote name is origin
    • 使用同样的方法将tags都推到azure中
      • git push azure refs/tags/*:refs/tags/*

    过滤分支

    git branch -a --list 'o*/chuck/*'

    在过滤远程分支的时候,remote name也在过滤里面,pattern可以限制remote name。

    remotes/origin/chuck/configuration
    remotes/origin/chuck/configuration-uk6.3
    remotes/origin/chuck/master

    What is the format of <pattern> in git-branch --list

    Quoting from that same manual page you linked:

    If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches. If a <pattern> is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns. Note that when providing a <pattern>, you must use --list; otherwise the command is interpreted as branch creation.

    So the answer, at least according to the documentation, is that "it is used as a shell wildcard". This assumes, of course, that you know what the phrase "shell wildcard" means—and more importantly, it's wrong, since a straight shell wildcard would not match across the /.

    The documentation should say something like: "The pattern acts much like a shell wildcard / glob pattern, except that slashes are not treated specially, so that a*b matches both accb and ac/cb, and a[bc/]* matches all of a/d, abcd, ac/cb, and accb."

    Examples:

    $ git branch -a
      a/d
      abcd
      ac/cb
      accb
    * master
    $ git branch --list 'a*b'
      ac/cb
      accb
    $ git branch --list 'a[bc/]*'
      a/d
      abcd
      ac/cb
      accb
    $ 
    
  • 相关阅读:
    B-线性代数-距离公式汇总
    B-线性代数-范数
    B-线性代数-矩阵转置
    B-概率论-贝叶斯决策
    B-概率论-极大似然估计
    B-概率论-条件概率
    2018.1.7java转型
    追求
    面向心态
    数据类型和type函数
  • 原文地址:https://www.cnblogs.com/chucklu/p/11670097.html
Copyright © 2011-2022 走看看