【发布时间】:2012-11-21 01:50:00
【问题描述】:
我正在开发一个 django 应用程序,我正在使用 pip 来管理我的需求。如何安装特定 git 的提交?
在我的情况下,我需要安装这个提交: https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1
【问题讨论】:
标签: git installation commit pip
我正在开发一个 django 应用程序,我正在使用 pip 来管理我的需求。如何安装特定 git 的提交?
在我的情况下,我需要安装这个提交: https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1
【问题讨论】:
标签: git installation commit pip
您可以指定提交哈希、分支名称、标签。
对于分支名称和标签,你也可以安装一个压缩的发行版。这更快、更高效,因为它不需要克隆整个存储库。 GitHub 会自动创建这些捆绑包。
哈希:
$ pip install git+git://github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1
分行名称
使用 git
$ pip install git+git://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+git://github.com/aladagemre/django-notification.git@v2.1.0
或来自源包
$ pip install https://github.com/aladagemre/django-notification/archive/v2.1.0.tar.gz
这是一个没有详细记录的功能,但您可以在https://pip.pypa.io/en/latest/topics/vcs-support/找到更多信息
【讨论】:
Could not find a tag or branch '2927346f4c513a217ac8ad076e494dd1adbf70e1', assuming commit.
git+命令的HTTPS版本:pip install git+https://github.com/gpoore/codebraid@011464539bfb09b8611c8aef0d543532cea958bf。这对于公司 http 代理背后的人来说可能很重要。
只需添加以下行,就可以在项目中使用 requirements.txt 文件自动安装 python 包:
package-name -e git+https://github.com/owner/repository.git@branch_or_commit#egg={package-name}
然后运行命令行:
$ pip install -r requirements.txt
【讨论】:
pip install -r requirements.txt 引发“无法检测到需求名称,请使用 #egg= 指定一个”。但它适用于格式 '-e git+github.com/owner/repository.git#egg=branch_or_commit'
python-openid -e git+https://github.com/openid/python-openid.git@d093a0919198eb53826ae5753e517af10ad95d5b#egg={python-openid}
对@hugo-tavares 回答的额外评论:
如果是私有 GitHub 存储库,则需要使用:
pip install git+ssh://git@github.com/....
在你的情况下:
pip install git+ssh://git@github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1
【讨论】:
如果你想创建一个egg包,你仍然可以使用相同的@branch_or_commit appendage:pip install git+ssh://git@github.com/myrepo.git@mybranch#egg=myeggscript
【讨论】: