zoukankan      html  css  js  c++  java
  • 在 Gerrit 仓库中创建空分支

    .

    .

    .

    .

    .

    Git 仓库可以创建不带有历史记录的空分支,但 Gerrit 无法直接创建空分支,于是需要通过绕一点弯子来实现。

    由于 Gerrit 创建的仓库没有工作空间,所以无法直接创建分支。因此我们需要在 Gerrit 服务器上先克隆一份本地仓库,然后在本地仓库的工作空间中创建空分支,最后绕过 Gerrit 直接将本地仓库的空分支推送到 Gerrit 的原始仓库中,以此来实现创建空分支的目的。

    在本例中,我们要为 SlideManager.git 仓库创建一个不包含历史记录的空分支:dev-blueberry。

    首先登陆 Gerrit 服务器,并来到 git 仓库所在的路径:

    >$ ssh gerrit@10.10.10.13
    >$ cd xxxx/gerrit/git/xxxx/packages/apps

    克隆本地仓库:

    >$ git clone SlideManager.git tmp.git
    Cloning into 'tmp.git'...
    done.

    在克隆下来的仓库中创建空分支:

    >$ cd tmp.git
    >$ git branch -a
    *master
      remotes/origin/HEAD -> origin/master
      remotes/origin/dev
      remotes/origin/master
      remotes/origin/qa
      remotes/origin/stable
    >$ git checkout --orphan dev-blueberry
    Switched to a new branch 'dev-blueberry'
    >$ cp .gitignore ..
    >$ git rm -rf .
    >$ mv ../.gitignore .

    现在,将空分支提交,并推送给 Gerrit 的本地仓库:

    >$ git status
    # On branch dev-blueberry
    #
    # Initial commit
    #
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #    .gitignore
    nothing added to commit but untracked files present (use "git add" to track)
    >$ git config user.name "root"
    >$ git config user.email "gerrit@mail.com"
    >$ git add .
    >$ git commit -m "New branch for dev blueberry."
    >$ git push origin HEAD:dev-blueberry
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 356 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 2 (delta 0)
    To /home/gerrit/xxxx/gerrit/git/xxxx/packages/apps/SlideManager.git
     * [new branch]      HEAD -> dev-blueberry

    大功告成,去 Gerrit site --> Browse --> Repositories --> Branches 网页刷新一下看看吧,刚创建的新分支应该已经存在了!

    最后,别忘了删掉 Gerrit 服务器上面的临时仓库:

    >$ cd ..
    >$ rm -rf tmp.git

    参考文献:

    在GIT中创建一个空分支

    作者:dybai
    出自:http://www.cnblogs.com/0xcafebabe
    赞赏:3Ky9q5HVGpYseBPAUTvbJBvM3h3FQ3edqr
    本作品采用知识共享署名-相同方式共享 3.0 中国大陆许可协议进行许可。
    欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

  • 相关阅读:
    数据仓库_Linux(3)
    2.1(构造序对)
    要修改一万个位置的jdk版本
    8个球7个一样重的,有一个偏重,一个天平,如何两次找出偏重的小球
    玄学
    异常:java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag
    提高输入效率
    fan
    idea
    打印整数的补码
  • 原文地址:https://www.cnblogs.com/0xcafebabe/p/14886194.html
Copyright © 2011-2022 走看看