![]() ![]() (You may need sudo, and you may need to install pip before you can use it, and so on, but since we know nothing about your platform or your level of knowledge, there's no way to guess exactly what you need. If so, the exact same readme document that told you how to do git.Git().clone("git:///platform/manifest.git") will also tell you how to install it.īut most likely, all you need is something like pip install pygit2 or pip install GitPython or something like that. I used GitPython library for cloning from git in my python function and my code snippet as follows: from git import Repo Repo.clonefrom (' ', /home/antro/Project/') It clones from master branch. Since you didn't show what the error was beyond "didn't work", it's hard to guess what exactly your problem was.īut I'm guessing the problem is that import git raised an ImportError, because you never installed the git module that you're trying to use. 11 I tried to clone a repository from git using GitPython in python function. You can either shell out (via os.system or subprocess) or use the GitPython package. ![]() It should already be installed when you set up your WSL installation, but if it isn't this. ![]() Side note: take a look at PIP which is designed to help install common packages. In WSL distros like Ubuntu and Debian you can install Git using the command sudo apt install git. git("status") raises an exception if you're not in a git repo). Git("clone", "git:///platform/manifest.git", "-b", "jb_2.5")Ĭhanging it to subprocess.check_output allows you to see the output git prints, instead of determining success (e.g. Return subprocess.check_call( + list(args)) Limiting the user to git commands is important for security purposes otherwise asking for a git url and using other techniques could result in loss of data or other malicious attacks. You can define a git function that allows you to make calls to git. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |