Giter Club home page Giter Club logo

github2file's Introduction

GitHub Repository to File Converter

This Python script allows you to download and process files from a GitHub repository, making it easier to share code with chatbots that have large context capabilities but don't automatically download code from GitHub.

Features

  • Download and process files from a GitHub repository
  • Support for both public and private repositories
  • Filter files based on programming language (Python or Go)
  • Exclude certain directories, file types, and test files
  • Remove comments and docstrings from Python source code (optional)
  • Specify a branch or tag to download from (default: "master")

Usage

To download and process files from a public GitHub repository, run the following command:

python github2file.py https://github.com/username/repository

For a private repository, use the following format:

python github2file.py https://<USERNAME>:<GITHUB_ACCESS_TOKEN>@github.com/username/repository

Replace <USERNAME> with your GitHub username and <GITHUB_ACCESS_TOKEN> with your GitHub personal access token.

Optional Arguments

  • --lang: Specify the programming language of the repository. Choices: "go" or "python" (default: "python").
  • --keep-comments: Keep comments and docstrings in the source code (only applicable for Python).
  • --branch_or_tag: Specify the branch or tag of the repository to download (default: "master").

Example

To download and process files from the Hugging Face Transformers repository, run:

python github2file.py https://github.com/huggingface/transformers

This will create a file named transformers_python.txt containing the combined Python source code from the repository.

To download and process files from a private repository, run:

python github2file.py https://<USERNAME>:<GITHUB_ACCESS_TOKEN>@github.com/username/private-repo

Output

The script will create a file named repository_language.txt (e.g., transformers_python.txt) containing the combined source code from the specified repository. You can then share this file with chatbots like Claude for further analysis or discussion.

Requirements

  • Python 3.x
  • requests library

License

This project is open-source and available under the MIT License.

github2file's People

Contributors

ehartford avatar georgeantonopoulos avatar imagineer99 avatar nkkko avatar ohadrubin avatar oslook avatar raghav3095 avatar twilwa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.