获取分支的特定版本 [英] Getting a particular version of a branch
问题描述
有没有办法下载特定版本的分支?
特别是我想要做一个 https://github.com/Theano/Theano 现在,并保存一系列关于如何从github获得完全相同版本的说明,不管将来的提交是什么。
更新
如果没有进一步的变化,有一个更简单的方法可以在github上做到这一点。在github中,您可以通过URL从浏览器导航到存储库的树视图。
https:// github的.com /< repo_name> /树/< commit_sha>
点击右侧导航栏上的下载ZIP按钮,将会下载资源库到特定的提交。
原始答案 我认为一种方法让你的用户(或者将要阅读你的指令的人)更轻松地克隆整个存储库。然后,如果当前的 HEAD
commit是您想要的版本,并且您不打算对存储库进行更改/合并更改,则可以将用户引导至此新存储库;可能标记它会是一个好主意。
否则,您可以通过特定的提交在您的新存储库中创建一个分支(和一个标签):
$ git checkout -b new_branch commit_sha //其中commit_sha指向您想要的版本
然后,您可以在克隆存储库后,将您的用户引用到存储库中的此新分支(或标记)。
我不认为有一种简单的方法克隆原始仓库,而不使用 git reset
。
Is there a way to download a particular version of a branch?
In particular I'd like to do a git clone of https://github.com/Theano/Theano now, and save a set of instructions on how to get the exact same version from github, regardless of future commits.
UPDATE
There is an easier way to do this on github if no further changes are expected. In github, you can navigate to the 'tree view' of a repository from your browser via the URL
https://github.com/<repo_name>/tree/<commit_sha>
Clicking on the 'Download ZIP' button on the right-hand navigation bar will download the codes of the repository up to that particular commit.
ORIGINAL ANSWER
I think one way to make your user's (or whoever will be reading your instructions) life easier is to clone the entire repository as-is. Then if the current HEAD
commit is the version you want and you don't plan on making/merging changes to your repository, you can just refer your user to this new repository; probably tagging it will be a good idea.
Otherwise, you can create a branch (and a tag) in your new repository with the specific commit by doing:
$ git checkout -b new_branch commit_sha // where commit_sha points to the version you wanted
Then you can refer your user to this new branch (or tag) in your repository, after they have cloned your repository.
I don't think there is a simple way to clone the original repository from an old commit without using git reset
.
这篇关于获取分支的特定版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!