Ruibin.Chow
Ruibin.Chow

Reputation: 93

Just download .git directory from github

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:

How do I find the .git directory from GitHub or my private gitlib and how to download it?

Upvotes: 2

Views: 3092

Answers (1)

VonC
VonC

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

Related Questions