简体   繁体   English

有没有办法不用git bash之类的通过代码安装解压github仓库?

[英]Is there any way to install and unpack a github repository through code without using git bash and the like?

Currently I have a problem where I need to install all contents of a github repository ( https://github.com/reversinglabs/reversinglabs-yara-rules ) through code without using git bash or the like.目前我有一个问题,我需要通过代码安装 github 存储库( https://github.com/reversinglabs/reversinglabs-yara-rules )的所有内容,而不使用 git bash 等。 In this case I need to fully install the yara repository from said github. Any one knows a way to do it in c,c++,c#,python?在这种情况下,我需要从 github 完全安装 yara 存储库。有人知道在 c、c++、c#、python 中执行此操作的方法吗?

Unfortunately till now I have yet to succeed in any way.不幸的是,直到现在我还没有以任何方式取得成功。

It's not clear what part of bash, etc, you do not want to use.不清楚 bash 等的哪些部分您不想使用。 A simple way otherwise is to just call git through std::system()一个简单的方法是通过std::system()调用 git

#include <cstdlib>

int main(int argc, char**argv) {
    std::system("git clone ...");
}

I have used it in many cases where I need to integrate git commands in a c++ program.我用过很多需要在c++程序中集成git命令的情况。

GitHub offers a zip download of all the code it hosts. GitHub 提供它托管的所有代码的 zip 下载。 Use whatever language and library you like to do the equivalent of:使用您喜欢的任何语言和库来执行以下操作:

curl -o yara-rules.zip https://github.com/reversinglabs/reversinglabs-yara-rules/archive/refs/heads/develop.zip 
unzip yara-rules.zip

only if you are on linux you can use:仅当您使用 linux 时,您才可以使用:

#Python 
import os 
url = input("Url: ")
os.system("git clone " + url)

or in c++或在 c++

#include <iostream>
using namespace std;
int main()
{
   string inputUrl;
   cin >> inputUrl;
   inputUrl = "git clone " + inputUrl;
   system (inputUrl.c_str()); //You need to convert it with .c_str()
}

Hope that this can be useful!希望这有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用git-bash用pip安装github软件包 - Trying to install github package with pip using git-bash / bin / env:python:没有这样的文件或目录(Windows通过Git Bash尝试安装新的Parse Cloud Code) - /bin/env: python: No such file or directory (Windows through Git Bash trying to install new Parse Cloud Code) 我正在尝试通过 git bash 克隆 github 代码。当我尝试编写以下代码时,它显示找不到命令 - I am trying to clone a github code through git bash. When I try writing the following code it shows Command not found 在不知道所有者的情况下通过API找到GitHub存储库 - Find GitHub repository through the API without knowing the owner 在不使用 *(星号)的情况下解压 - Unpack without using * (asterisk) 无法安装github存储库 - Can't install a github repository 如何使用 gitpython 克隆 git 存储库而不与 git 关联? - How to clone a git repository without association with git using gitpython? Python / pip,如何从github安装特定版本的git存储库(什么是正确的URL)? - Python / pip, how do I install a specific version of a git repository from github (what is the correct url)? 有什么方法可以打开 git-bash 并在 Python 中发送命令? - Is there any way to open git-bash and send commands in Python? 如何使用pip install git +保存存储库? - How to save repository using pip install git+?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM