使用 pip 安装特定的 git 提交

问题描述 投票:0回答:5

我正在开发一个 django 应用程序,并使用 pip 来管理我的需求。我怎样才能安装特定的 git 提交?

就我而言,我需要安装此提交: https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1

git installation commit pip
5个回答
496
投票

您可以指定提交哈希、分支名称、标签。

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

哈希:

$ pip install git+https://github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1

分行名称

使用 git

$ pip install git+https://github.com/aladagemre/django-notification.git@cool-feature-branch

或来自源包

$ pip install https://github.com/aladagemre/django-notification/archive/cool-feature-branch.tar.gz

标签

使用 git

$ pip install git+https://github.com/aladagemre/[email protected]

或来自源包

$ pip install https://github.com/aladagemre/django-notification/archive/v2.1.0.tar.gz

这是一个没有详细记录的功能,但您可以在 https://pip.pypa.io/en/latest/topics/vcs-support/

找到更多信息

33
投票

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

package-name -e git+https://github.com/owner/repository.git@branch_or_commit#egg={package-name}

并运行命令行:

$ pip install -r requirements.txt


26
投票

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

如果是私有 GitHub 存储库,则需要使用:

pip install git+ssh://[email protected]/....

您的情况:

pip install git+ssh://[email protected]/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1

4
投票

如果你想创建一个egg包,你仍然可以使用相同的@branch_or_commit附件:

pip install git+ssh://[email protected]/myrepo.git@mybranch#egg=myeggscript


0
投票

在 24.2 点上,简单地说

git+https://github.com/owner/repository.git@branch_or_commit#egg={package-name}

本身在requirements.txt中作为一行,它将通过运行来工作

pip install -r requirements.txt
© www.soinside.com 2019 - 2024. All rights reserved.