简体   繁体   English

如何从github pip安装特定日期

[英]how to pip install from github for specific date

I need to install with pip from a git hub but wanted the repository from May 4th. 我需要从git hub安装pip,但是需要5月4日的存储库。 Can anyone help me on that? 任何人都可以帮助我吗?

for instance if I want to pip install a repo's specific branch I can use below command : 例如,如果我想要pip install repo的特定分支,我可以使用下面的命令:

pip install https://github.com/user/repo.git@branch

but don't know how get it by date other than branch name? 但是不知道除了分支名称之外如何按日期获取它?

Well, you can replace <branch> with a desired commit <sha-1> . 好吧,你可以用期望的提交<sha-1>替换<branch> <sha-1> I've just checked it with bpython: 我刚用bpython检查过它:

$ pip install --upgrade --user git+https://github.com/bpython/bpython.git@f2014dbae31313571cc9c26f51a14f4fda09d138
Collecting git+https://github.com/bpython/bpython.git@f2014dbae31313571cc9c26f51a14f4fda09d138
  Cloning https://github.com/bpython/bpython.git (to f2014dbae31313571cc9c26f51a14f4fda09d138) to /tmp/.private/alex/pip-tQcJmV-build
  Could not find a tag or branch 'f2014dbae31313571cc9c26f51a14f4fda09d138', assuming commit.
...

Another question is how to get a commit for a given date. 另一个问题是如何获得给定日期的提交。

The first option is to open a browser, find an appropriate commit and manually form a proper URL for pip install . 第一个选项是打开浏览器,找到适当的提交并手动形成适当的pip install URL。 Actually I used this way for the example above. 实际上我用这种方式作为上面的例子。

But you may want to automate things. 但是你可能想要自动化。 I would do a local shallow copy of a given repo from github: 我会从github做一个给定repo的本地浅拷贝:

git clone --depth 10 --single-branch --branch master https://github.com/bpython/bpython.git

(take only 10 last commits from master branch of bpython official repo) (从bpython官方回购的主分支bpython最后一次提交)

Then, determine what commit satisfies the date restrictions: 然后,确定满足日期限制的提交:

COMMITID=$(git rev-list -n 1 --before '2016/04/07 16:36:15 2016 +0000' HEAD)

Then, use the commit id in the pip install command: 然后,使用pip install命令中的commit id:

pip install --upgrade --user git+file:///tmp/.private/alex/bpython@${COMMITID}

You could clone the repo, checkout the date you want locally and pip install in dev mode: 您可以克隆存储库,在本地签出您想要的日期,并在开发模式下进行pip安装:

git clone https://github.com/user/repo.git
cd repo
git checkout `git rev-list -n 1 --before="2016-03-03 13:37" master`
pip install -e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM