cgit.sh
is a Bash script designed to clone a GitHub repository and concatenate all relevant source code files into a single text file. It supports flexible options for filtering by file extension and directory, making it ideal for preparing code for submission to AI chat bots.
- Flexible File Filtering: Specify which file extensions to include or exclude in the concatenation process.
- Directory Filtering: Limit the search to specified directories within the repository.
- Repository Retention: Option to keep the cloned repository in the current directory after processing.
- Git installed on your machine.
- Bash environment capable of executing shell scripts.
Setup Instructions
Click to show Windows setup instructions
-
Choose your preferred method:
Option A: PowerShell (Recommended)
- Install Git for Windows from git-scm.com
- During installation, ensure "Git from the command line..." is selected
- This installation includes Git and Bash which will be available in PowerShell
- Open PowerShell
- Navigate to script directory
- Run script:
bash cgit.sh
Option B: Command Prompt (CMD)
- Install Git for Windows from git-scm.com
- During installation, ensure "Git from the command line..." is selected
- This installation includes Git and Bash which will be available in CMD
- Open Command Prompt
- Navigate to script directory
- Run script:
bash cgit.sh
Option C: Git Bash
- Install Git for Windows from git-scm.com
- During installation, select "Git Bash" option
- This installation provides a dedicated Bash terminal with Git included
- Right-click in your desired folder
- Select "Git Bash Here"
- Run script:
./cgit.sh
orbash cgit.sh
Click to show macOS setup instructions
- Install Git (if not already installed):
- Open Terminal
- Run
xcode-select --install
(installs Git and other developer tools) - Or install via Homebrew:
brew install git
- The script can be run directly from Terminal as macOS includes Bash by default
Click to show Linux setup instructions
- Install Git (if not already installed):
sudo apt update sudo apt install git
- Make the script executable:
chmod +x cgit.sh # or just run the script with bash bash cgit.sh
- Run directly from Terminal as shown in Usage section
./cgit.sh REPO_URL [EXTENSIONS] [DIRECTORIES] [--keep]
# or
bash cgit.sh REPO_URL [EXTENSIONS] [DIRECTORIES] [--keep]
# Concatonate all files with default extensions in entire repo
bash cgit.sh "https://github.com/user/repo"
# Concatonate .go and .txt files in app/ and cmd/ directories, keep downloaded copy of repo
bash cgit.sh "https://github.com/user/repo" "go,txt" "app,cmd" --keep
# Concatonate default extensions only in the src/ directory
bash cgit.sh "https://github.com/user/repo" "" "src"
# Process modified extension list in specific directories
bash cgit.sh "https://github.com/user/repo" "+html,go,-c" "app/html,cloud"
c cpp cc cxx java py js ts cs rb php html htm css swift kt kts go rs sh bat pl lua r m vb sql asm sc erl ex exs hs dart pas groovy f for f90 v vh sv pyx clj cljs md tsx jsx yaml yml json ini cfg xml ipynb