Reputation: 93
When you execute git init
in a new directory or an existing directory, Git creates a .git
directory, where almost all the contents of the Git store and operation are located in the directory.
If you want to back up or copy a library, basically copy this directory to other places.
And now, I just want to download .git
directory include contents from GitHub:
.git
files through Python language using request. (I don't want to pass by git long command)How do I find the .git directory from GitHub or my private gitlib and how to download it?
Upvotes: 2
Views: 3092
Reputation: 1330102
If you need only the .git content, you still need to use a git command:
git clone --bare https://github.com/<user>/<repo>
You will get a bare repo, one without working tree and only the .git content
See "Python way to clone a git repository" and gitpython-developers/GitPython
from git import Repo
Repo.clone_from(git_url, repo_dir, branch='master', bare=True)
With pygit2, use pygit2.clone_repository
:
clone_repository(url, path, bare=True)
Upvotes: 5