我需要从git中心安装pip,但希望从5月4日开始使用存储库。任何人都可以帮助我吗?如何从特定日期从github pip安装
例如,如果我想pip install
回购的具体分支我可以使用下面的命令:
pip install https://github.com/user/[email protected]
,但不知道如何比分支名其他日期怎么做呢?
我需要从git中心安装pip,但希望从5月4日开始使用存储库。任何人都可以帮助我吗?如何从特定日期从github pip安装
例如,如果我想pip install
回购的具体分支我可以使用下面的命令:
pip install https://github.com/user/[email protected]
,但不知道如何比分支名其他日期怎么做呢?
你可以克隆回购,结帐你在本地所需的日期和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
好了,你可以替换<branch>
与所需提交<sha-1>
。我刚刚用bpython检查过它:
$ pip install --upgrade --user git+https://github.com/bpython/[email protected]
Collecting git+https://github.com/bpython/[email protected]
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.
...
另一个问题是如何获取给定日期的提交。
第一个选项是打开浏览器,找到适当的提交并手动为pip install
形成正确的URL。其实我上面的例子是用这种方式。
但是你可能想自动化的东西。我会做一个给定的回购的地方浅拷贝从GitHub:
git clone --depth 10 --single-branch --branch master https://github.com/bpython/bpython.git
(从bpython
官方回购的主分支只拿10最后提交)
然后,确定什么样的commit满足日期限制:
COMMITID=$(git rev-list -n 1 --before '2016/04/07 16:36:15 2016 +0000' HEAD)
然后,使用提交ID在pip install
命令:
pip install --upgrade --user git+file:///tmp/.private/alex/[email protected]${COMMITID}
作弊! :)但是,我真的要依靠指定提交sha的本机pip机制来实现+1 – user3159253
。 –
有什么区别?你必须克隆回购以获取日期 – maxymoo