使用pip安装特定的git commit

kel*_*nfc 153 git install pip commit

我正在开发一个django应用程序,我正在使用pip来管理我的需求.如何安装特定的git提交?

在我的情况下,我需要安装此提交:https: //github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1

Hug*_*res 246

您可以指定提交哈希,分支名称,标记.

对于分支名称和标记,您还可以安装压缩分发.这样更快,更高效,因为它不需要克隆整个存储库.GitHub自动创建这些包.

哈希:

$ pip install git+git://github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1
Run Code Online (Sandbox Code Playgroud)

分店名称

用git

$ pip install git+git://github.com/aladagemre/django-notification.git@cool-feature-branch
Run Code Online (Sandbox Code Playgroud)

或来自源包

$ pip install https://github.com/aladagemre/django-notification/archive/cool-feature-branch.tar.gz
Run Code Online (Sandbox Code Playgroud)

标签

用git

$ pip install git+git://github.com/aladagemre/django-notification.git@v2.1.0
Run Code Online (Sandbox Code Playgroud)

或来自源包

$ pip install https://github.com/aladagemre/django-notification/archive/v2.1.0.tar.gz
Run Code Online (Sandbox Code Playgroud)

这是一个没有详细记录的功能,但您可以在https://pip.pypa.io/en/latest/reference/pip_install.html#git上找到更多信息.

  • 它将添加这个有趣的消息:`找不到标签或分支'2927346f4c513a217ac8ad076e494dd1adbf70e1',假设提交. (22认同)
  • @ vlad-ardelean关于如何告诉pip IT是一个提交的任何想法?这在我的部署脚本上已经过时了,我不想压制所有stderr. (10认同)
  • 另外,我要提到 `git+` 命令的 HTTPS 版本:`pip install git+https://github.com/gpoore/codebraid@011464539bfb09b8611c8aef0d543532cea958bf`。这对于企业 http 代理背后的人员来说可能很重要。 (3认同)

PGu*_*uiv 16

对@ hugo-tavares答案的额外评论:

如果它是私有GitHub存储库,您将需要使用:

pip install git+ssh://git@github.com/....
Run Code Online (Sandbox Code Playgroud)

在你的情况下:

pip install git+ssh://git@github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1
Run Code Online (Sandbox Code Playgroud)


man*_*ysz 12

只需添加以下行,就可以使用项目中的requirements.txt文件自动安装python包:

-e git+https://github.com/owner/repository.git@branch_or_commit

并运行命令行:

$ pip install -r requirements.txt

  • 对我来说(python3.5 virtualenv中的pip 9.0.1)它不起作用:`pip install -r requirements.txt` raise'无法检测需求名称,请用#egg ='指定一个.但它的格式为'-e git + https://github.com/owner/repository.git#egg=branch_or_commit' (13认同)
  • 我让它工作了,但这还不清楚。需要在行开头有“package_name -e ...”而不仅仅是“-e ...”。 (2认同)