Install specific git commit with pip

GitInstallationCommitPip

Git Problem Overview


I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?

In my case I need to install this commit: https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1

Git Solutions


Solution 1 - Git

You can specify commit hash, branch name, tag.

For the branch name and the tag, you can also install a compressed distribution. This is faster and more efficient, as it does not require cloning the entire repository. GitHub creates those bundles automatically.

hash:

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

branch-name

With git

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

or from source bundle

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

tag

with git

$ pip install git+git://github.com/aladagemre/django-notification.git@v2.1.0

or from source bundle

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

It is a not well-documented feature, but you can find more information at https://pip.pypa.io/en/latest/topics/vcs-support/

Solution 2 - Git

It's possible to automatically install a python package using the requirements.txt file on you project just by adding the following line:

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

and run the command line:

$ pip install -r requirements.txt

Solution 3 - Git

An extra comment to @hugo-tavares's answer:

If it's a private GitHub repository, you'll need to use:

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

In your case:

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

Solution 4 - Git

If you want to create an egg package, you can still use the same @branch_or_commit appendage: pip install git+ssh://[email protected]/myrepo.git@mybranch#egg=myeggscript

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkelwinfcView Question on Stackoverflow
Solution 1 - GitHugo TavaresView Answer on Stackoverflow
Solution 2 - GitmannyszView Answer on Stackoverflow
Solution 3 - GitPGuivView Answer on Stackoverflow
Solution 4 - GitDannidView Answer on Stackoverflow