Is it possible to clone only certain commit from a git repo with depth 1?
pip
package manager allows installing from various VCS including git
:
Pip currently supports cloning over git, git+http and git+ssh:
-e git://git.myproject.org/MyProject.git#egg=MyProject -e git开发者_开发问答+http://git.myproject.org/MyProject/#egg=MyProject -e git+ssh://git@myproject.org/MyProject/#egg=MyProject
Passing branch names, a commit hash or a tag name is also possible:
-e git://git.myproject.org/MyProject.git@master#egg=MyProject -e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject -e git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject
This is nice when the package is small, however, it becomes quite slow when the package is huge (e.g. Django). If I need just the last commit of master branch, then I could use --depth 1
parameter for git clone.
Is it possible to get only a certain commit without the full repo history in general? At least from github?
You can neither clone
nor fetch
from remote a particular commit, much less a depth of 1, due to security reasons: http://thread.gmane.org/gmane.comp.version-control.git/73368/focus=73994
http://git.661346.n2.nabble.com/Fetch-by-SHA-missing-td5604552.html
To the best of my knowledge, no. You may want to ask about this on the git mailing list.
You can use GitHub API to get last/any commit: http://developer.github.com/v3/repos/commits/#get-a-single-commit
It's not a git command, you'll need to make a HTTP request, parse JSON response and download files with diff-data.
精彩评论