相当于`svn export`或github解决方法的git [英] git equivalent to `svn export` or github workaround

查看:91
本文介绍了相当于`svn export`或github解决方法的git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从git存储库中获取单个文件。使用SVN,我可以使用 svn export 如下:

  sudo svn export http://www.example.com/repos/Trunk/pathtofile/file.ext 

只是下载文件,裸体,即没有任何存储库信息。



在git中是否有相当于 svn export

我得到的最接近的是 git show upstream / master:pathtofile / file.ext ,但这并不等同,因为您已经需要在git中repo for it work。



我有另一个选项,因为我使用的是github,试图 wget github原始文件。

  wget https://raw.github.com/< mygithubuser> /repo/master/pathtofile/file.ext?登录名=< mylogin>&安培;令牌=< notsurewhattoputhere> 

问题是回购是私人的,所以我需要提供一个令牌,我不确定如何生成并在 wget 中使用它?

解决方案

I没有检查过,但根据这个git hub页面,您的身份验证令牌已提供给您个人资料页。所以假设它是一个手动将其嵌入到命令中的选项,那么我会为此而努力。否则,我想你需要接受它作为这个命令将包含在脚本中的参数,或者可能在配置文件中。虽然我猜这两个选项都可能存在安全问题。


I want to fetch a single file from a git repository. Using SVN, I can use svn export as follows:

sudo svn export http://www.example.com/repos/Trunk/pathtofile/file.ext

This just downloads the file, naked, i.e without any repository info with it.

Is there an equivalent to svn export in git?

The closest I got was "git show upstream/master:pathtofile/file.ext" but this isn't really equivalent because you already need to be inside a git repo for it to work.

Another option I have, because I'm using github, is to try to wget the github raw file.

wget https://raw.github.com/<mygithubuser>/repo/master/pathtofile/file.ext?login=<mylogin>&token=<notsurewhattoputhere>

The problem is that the repo is private so I need to supply a token and I'm not sure how to generate this and use it in a wget?

解决方案

I've not checked, but according to this git hub page your authentication token is supplied on you profile page. So assuming it's an option to just manually embed it in the command, then I'd go for that. Otherwise I suppose you'd need to accept it as a parameter to the script this command will be contained in, or possibly in a configuration file. Although I guess both of those options could have security concerns.

这篇关于相当于`svn export`或github解决方法的git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆