本文翻译自:How to git-svn clone the last n revisions from a Subversion repository?

Problem 问题

How do you create a shallow copy with git-svn from a Subversion repository, eg how do you pull only the last three revisions? 如何使用来自Subversion存储库的git-svn创建浅表副本,例如,如何仅提取最后三个修订版?

The git clone command can get the last n revisions from a Git repository if you use the option --depth , ie you get a shallow copy of the repository. 如果使用选项--depthgit clone命令可以从Git存储库获取最后n个修订版,即获得存储库的浅表副本。 Example: 例:

git clone --depth 3 git://some/repo myshallowcopyrepo

Is there a similar option for git-svn? git-svn有类似的选择吗?

My discoveries so far 到目前为止我的发现

So far I've only found the -rN option where N is the revision to pull. 到目前为止,我只找到-rN选项,其中N是要拉的修订版。 Example: 例:

git svn clone -rN svn://some/repo

According to the documentation there is the possibility to use -r$REVNUMBER:HEAD . 根据文档,有可能使用-r$REVNUMBER:HEAD I tried the following to get the last 3 revisions which returned an error message. 我尝试了以下内容来获取最后3个修订版,它们返回了一条错误消息。

$ git svn clone --prefix=svn/ -s -rHEAD~3:HEAD http://some/svn/repo .
revision argument: HEAD~3:HEAD not understood by git-svn

So I replaced HEAD~3 with the actual number of the third but last revision 534. That worked, but that requires me to first figure out the revision number of the third but last commit. 所以我用第三个但最后一个修订版534的实际数字替换了HEAD~3 。这有效,但这要求我首先找出第三个但最后一次提交的修订号。

$ git svn clone --prefix=svn/ -s -r534:HEAD http://some/svn/repo .

Documentation 文档

git-clone 混帐克隆

git-svn GIT-SVN


#1楼

参考:https://stackoom.com/question/38Lb/如何从Subversion存储库中git-svn克隆最后n个修订版


#2楼

I find myself using the following often to get a limited number of revisions out of our huge subversion tree (we're soon reaching svn revision 35000). 我发现自己经常使用以下内容从我们巨大的颠覆树中获得有限数量的修订(我们很快就会达到svn修订版35000)。

# checkout a specific revision
git svn clone -r N svn://some/repo/branch/some-branch
# enter it and get all commits since revision 'N'
cd some-branch
git svn rebase

And a good way to find out where a branch started is to do a svn log it and find the first one on the branch (the last one listed when doing): 找到分支开始位置的一个好方法是执行svn log并找到分支上的第一个(执行时列出的最后一个):

svn log --stop-on-copy svn://some/repo/branch/some-branch

So far I have not really found the hassle worth it in tracking all branches. 到目前为止,我还没有真正找到跟踪所有分支的麻烦。 It takes too much time to clone and svn and git don't work together as good as I would like. 克隆和svn需要花费太多时间,并且git不能像我想的那样一起工作。 I tend to create patch files and apply them on the git clone of another svn branch. 我倾向于创建补丁文件并将其应用于另一个svn分支的git clone。


#3楼

... 7 years later, in the desert, a tumbleweed blows by ... ... ... 7年后,在沙漠中,一个风滚草吹...

I wasn't satisfied with the accepted answer so I created some scripts to do this for you available on Github . 我对接受的答案不满意,所以我在Github上为你创建了一些脚本。 These should help anyone who wants to use git svn clone but doesn't want to clone the entire repository and doesn't want to hunt for a specific revision to clone from in the middle of the history (maybe you're cloning a bunch of repos). 这些应该可以帮助任何想要使用git svn clone但不想克隆整个存储库并且不想在历史中间寻找克隆的特定修订版本的人(也许你正在克隆一堆回购)。 Here we can just clone the last N revisions: 在这里,我们可以克隆最后N个修订:

Use git svn clone to clone the last 50 revisions 使用git svn clone克隆最近50个修订版

# -u    The SVN URL to clone
# -l    The limit of revisions
# -o    The output directory./git-svn-cloneback.sh -u https://server/project/trunk -l 50 -o myproj --authors-file=svn-authors.txt

Find the previous N revision from an SVN repo 从SVN仓库中找到以前的N版本

# -u    The SVN URL to clone
# -l    The limit of revisions./svn-lookback.sh -u https://server/project/trunk -l 5

#4楼

You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at ( -r$REV:HEAD ). 您已经发现了在Git-SVN中指定浅层克隆的最简单方法,方法是在( -r$REV:HEAD )指定要启动克隆的SVN修订版号。

For example: git svn clone -s -r1450:HEAD some/svn/repo 例如: git svn clone -s -r1450:HEAD some/svn/repo

Git's data structure is based on pointers in a directed acyclic graph (DAG), which makes it trivial to walk back n commits. Git的数据结构基于有向非循环图(DAG)中的指针,这使得返回n提交变得微不足道。 But in SVN ( and therefore in Git-SVN) you will have to find the revision number yourself. 但是在SVN(因此在Git-SVN中)你必须自己找到修订号。

如何从Subversion存储库中git-svn克隆最后n个修订版?相关推荐

  1. Subversion存储库中“分支”,“标记”和“主干”的含义是什么?

    我已经在Subversion(我猜通用存储库)讨论中看到了很多这样的话. 在过去的几年里,我一直在为我的项目使用SVN,但我从未掌握过这些目录的完整概念. 他们的意思是什么? #1楼 现在这就是软件开 ...

  2. 如何仅从git存储库中稀疏签出单个文件?

    如何从git仓库中检出一个文件? #1楼 git checkout branch_or_version-路径/文件 示例: git checkout HEAD -- main.c #2楼 如果您已经有 ...

  3. 另一个git进程似乎在这个存储库中运行

    我正在尝试学习如何使用Git,并创建了一个包含HTML,CSS和Javascript文件的小项目. 我从我的基本空项目中创建了一个分支,然后对我的代码进行了一些更改. 我尝试暂存更改,但我收到以下错误 ...

  4. 将子目录分离(移动)到单独的Git存储库中

    我有一个Git存储库,其中包含许多子目录. 现在,我发现一个子目录与另一个子目录无关,应该将其分离到单独的存储库中. 如何在保留子目录中文件历史记录的同时执行此操作? 我想我可以制作一个克隆并删除每个 ...

  5. 在Git存储库中查找并恢复已删除的文件

    假设我在Git存储库中. 我删除文件并提交更改. 我继续工作并做出更多承诺. 然后,我发现需要还原该文件. 我知道我可以使用git checkout HEAD^ foo.bar来签出文件,但是我真的不 ...

  6. 从Git存储库中删除文件而不从本地文件系统中删除它

    我的初始提交包含一些日志文件. 我已将*log添加到我的.gitignore ,现在我想从我的存储库中删除日志文件. git rm mylogfile.log 将从存储库中删除文件,但也将从本地文件系 ...

  7. .git文件夹_将Git存储库中的文件夹转换为全新的存储库

    前提 如果您创建存储库的新克隆,则在将文件夹拆分到单独的存储库时,不会丢失任何Git历史记录或更改. 步骤 打开终端. 将当前工作目录更改为要创建新存储库的位置. 克隆包含子文件夹的存储库. $ gi ...

  8. git 初始化git存储库_什么不保存到Git存储库中

    git 初始化git存储库 You should not commit these four types of files into your Git repository. 您不应将这四种类型的文件 ...

  9. git git 查看远程库_如何从Git远程存储库中提取

    git git 查看远程库 Note: This the fourth video in the Git for beginners series. Watch the first video her ...

最新文章

  1. 电视剧《都挺好》给我的启示
  2. unicode环境下用CFile读取txt的若干疑惑,该如何处理
  3. java自学语法_Java自学笔记(一):基础知识
  4. 【信息化】CIO议题营销模型
  5. 为什么梯度的方向与等高线切线方向垂直?
  6. 实例演示使用HiBench对Hadoop集群进行基准测试
  7. 第7章 C控制语句:分支和跳转
  8. 完美世界2020编程题-救雅典娜 英雄AB PK
  9. python的setting怎么找_django项目的配置文件settings.py详解
  10. centos 等保三级_等保测评三级整改-身份鉴别
  11. tf 设置多显卡_用树莓派搭建私人简易网盘 2/5 树莓派4B初始设置
  12. 人大金仓数据库使用uuid
  13. c语言是结构化 模块化的编程语言,结构化程序设计和模块化结构
  14. 柯美服务器处理文件慢,处理打印机在打印文件时打印速度过慢的原因 看完你就知道了...
  15. 【UI界面开发】基本组件——滑杆
  16. 人工神经网络原理及应用,人工神经网络教程PDF
  17. 计算机网络-IP和子网掩码及网络划分
  18. c语言省二机考和笔试,计算机二级都是上午考试吗
  19. 博客园+CSDN文章
  20. 一套极简的MQTT使用接口EasyMqttClient

热门文章

  1. Android开发之ContentProvider结合LoaderManager加载数据(图文源代码分享)
  2. Android面试题目之四: 归并排序
  3. linux查找技巧: find grep xargs linux系统信息查看大全
  4. Android onMeasure过程分析
  5. webstorm 使用svn
  6. 第八周项目三-指向学生类的指针
  7. 【Android UI设计与开发】第10期:顶部标题栏(一)ActionBar详细概述和简单示例
  8. 字符串与base64相互转换
  9. [大话数据结构-读书笔记] 栈
  10. vue-router 去掉#