zoukankan      html  css  js  c++  java
  • git原理:引用规格

    引用规格(refspec):就是在 .git/config 里面那个配置远程仓库的东西

    [remote "origin"]
    url = https://github.com/test/demo
    fetch = +refs/heads/*:refs/remotes/origin/*

    格式:由一个可选的 + 号和<src>:<dst>组成
      +:即使在不能快进的情况下也强制更新引用
      <src>:代表远程版本库中的引用
      <dst>:远程引用在本地所对应的位置

    引用规格由git remote add命令自动生成,git获取服务器中refs/heads/下面的所有引用,并将他们写入本地的refs/remotes/origin中,所以,如果服务器上有一个master分支,在本地这三种写法是等价的:
      git log origin/master
      git log remotes/origin/master
      git log refs/remotes/origin/master
    他们都会被扩展成 refs/remotes/origin/master

    每次只拉取master分支,而不是所有分支,修改文件为:
      fetch = +refs/heads/master:refs/remotes/origin/master

    将远程master分支拉取到本地的origin/mymaster分支:
      git fetch origin msater:refs/remotes/origin/mymaster

    在配置文件中指定多个用于获取操作的引用规格,比如:
      [remote "origin"]
      url = https://github.com/test/demo
      fetch = +refs/heads/master:refs/remotes/origin/master
      fetch = +refs/heads/experiment:refs/remotes/origin/experiment
    这样,每次拉取的时候都会拉取到master和experiment两个分支

    模式不支持部分通配符,所以像下面这样的引用规格是不合法的:
      fetch = +refs/heads/qa*:refs/remotes/origin/qa*
    可以通过子目录的方式来达到类似目的:
       假设QA 团队推送了一系列分支,只想拉取master和QA的分支,其他的不关心:
      [remote "origin"]
      url = https://github.com/test/demo
      fetch = +refs/heads/master:refs/remotes/origin/master
      fetch = +refs/heads/qa/*:refs/remotes/origin/qa/*

    推送:
      命令行:git push origin master:refs/heads/qa/master
      配置文件:push = refs/heads/master:refs/heads/qa/master

    删除:
      $ git push origin :topic
      因为引用规格的格式是 <src>:<dst>,所以把 <src> 留空,意味着把远程版本库的 topic 分支定义为空值,也就是删除它。

  • 相关阅读:
    Flask--Config研究
    Python和Mongodb
    使用 wsgiref 创建WSGI APP
    如何使用werkzeug创建WSGI APP
    编程常用数据结构与函数总结(vector、list、stack、deque、字符串)
    LeetCode 841 钥匙和房间(怎么减少程序运行时间、BFS、lambda、sync_with_stdio、cin.tie)
    卡尔曼滤波总结
    ROS之rviz显示历史运动轨迹、路径的各种方法(visualization_msgs/Marker、nav_msgs/Path)
    二叉树前序遍历、中序遍历、后序遍历、层序遍历的直观理解
    MathType常用快捷键
  • 原文地址:https://www.cnblogs.com/413xiaol/p/7834578.html
Copyright © 2011-2022 走看看