gitign


Namegitign JSON
Version 0.17 PyPI version JSON
download
home_pagehttps://github.com/cumulus13/gitignore
SummaryA powerful and user-friendly Python script to generate `.gitignore` files with default entries, custom patterns, or templates from gitignore.io
upload_time2025-08-16 16:50:23
maintainerNone
docs_urlNone
authorHadi Cahyadi
requires_python>=3.6
licenseMIT
keywords gitignore gitignore.io rich terminal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ๐Ÿš€ GitIgnore Generator

A powerful and user-friendly Python script to generate `.gitignore` files with default entries, custom patterns, or templates from [gitignore.io](https://gitignore.io). Features rich console output and smart duplicate detection.

## โœจ Features

- ๐ŸŽฏ **Smart Generation**: Create `.gitignore` files with sensible defaults
- ๐Ÿ”„ **Template Support**: Fetch templates from gitignore.io for popular frameworks
- ๐Ÿ›ก๏ธ **Duplicate Prevention**: Automatically detects and prevents duplicate entries
- ๐Ÿงน **Cleanup Tool**: Remove duplicates from existing `.gitignore` files
- ๐Ÿ“– **Syntax Highlighting**: Beautiful syntax-highlighted file reading
- ๐ŸŽจ **Rich Console Output**: Colorful and informative terminal interface
- โšก **Auto-Append Mode**: Intelligently appends to existing files
- ๐Ÿ’พ **Backup Support**: Creates backups when cleaning files

## ๐Ÿ“‹ Requirements

- Python 3.6+
- Rich library (`pip install rich`)

## ๐Ÿ”ง Installation

1. Clone or download the script:
```bash
git clone https://github.com/cumulus13/gitignore.git
cd gitignore
```

2. Install dependencies:
```bash
pip install rich
```

3. Make the script executable (optional):
```bash
chmod +x gitignore.py
```

## ๐Ÿš€ Quick Start

### Basic Usage

```bash
# Generate .gitignore with default entries
python gitignore.py

# Add custom entries (auto-appends if file exists)
python gitignore.py "*.log" "temp/" "config.local"

# Use templates from gitignore.io
python gitignore.py -t python node react

# Read existing .gitignore with syntax highlighting
python gitignore.py -r
```

## ๐Ÿ“– Usage Examples

### ๐ŸŽฏ Creating New .gitignore Files

```bash
# Basic generation with defaults
python gitignore.py

# Generate with custom entries
python gitignore.py "*.tmp" "debug.log" "*.cache"

# Generate with templates
python gitignore.py -t python django

# Generate without default entries
python gitignore.py --no-defaults -t python

# Force overwrite existing file
python gitignore.py -f "*.backup"
```

### ๐Ÿ“ Adding to Existing Files

```bash
# Auto-append mode (detects existing file)
python gitignore.py "new_pattern" "*.local"

# Explicit append mode
python gitignore.py -a "build/" "dist/"

# Add multiple entries with different separators
python gitignore.py "file1,file2;file3|file4"
```

### ๐Ÿงน Cleaning Duplicates

```bash
# Preview duplicates without changes
python gitignore.py --clean --preview

# Remove duplicates (creates backup by default)
python gitignore.py --clean

# Remove duplicates without backup
python gitignore.py --clean --no-backup

# Clean file in specific directory
python gitignore.py --clean -p /path/to/project
```

### ๐Ÿ“– Reading Files

```bash
# Read .gitignore with syntax highlighting
python gitignore.py -r

# Read from specific directory
python gitignore.py -r -p /path/to/project
```

## โš™๏ธ Command Line Options

### Main Options

| Option | Short | Description |
|--------|-------|-------------|
| `--path` | `-p` | Target directory path (default: current directory) |
| `--data` | `-d` | Additional entries (can be repeated) |
| `--template` | `-t` | Templates from gitignore.io |
| `--append` | `-a` | Append to existing file without overwrite |
| `--force` | `-f` | Skip confirmation prompt |
| `--no-defaults` |  | Don't include default entries |
| `--read` | `-r` | Read and display .gitignore content |
| `--version` | `-v` | Show version information |

### Cleaning Options

| Option | Description |
|--------|-------------|
| `--clean` | Clean duplicate entries |
| `--preview` | Preview changes without applying |
| `--no-backup` | Don't create backup file |

## ๐ŸŽจ Default Entries

The script includes these default entries by default:

```gitignore
*.pyc
*.bak
*.zip
*.rar
*.7z
*.mp3
*.wav
*.sublime-workspace
.hg/
build/
*.hgignore
*.hgtags
*dist/
*.egg-info/
traceback.log
__pycache__/
*.log
```

## ๐ŸŒŸ Advanced Features

### ๐Ÿ“ Multiple Entry Formats

The script supports various entry formats:

```bash
# Comma-separated
python gitignore.py "file1,file2,file3"

# Space-separated (use quotes)
python gitignore.py "file1 file2 file3"

# Semicolon-separated
python gitignore.py "file1;file2;file3"

# Array-like format
python gitignore.py "[file1,file2,file3]"

# Quoted entries
python gitignore.py '"special file.txt"' "'another file.log'"
```

### ๐Ÿ”„ Template Examples

Popular templates available from gitignore.io:

```bash
# Programming languages
python gitignore.py -t python
python gitignore.py -t node javascript
python gitignore.py -t java maven
python gitignore.py -t csharp dotnetcore

# Frameworks
python gitignore.py -t react vue angular
python gitignore.py -t django flask
python gitignore.py -t rails laravel

# IDEs and editors
python gitignore.py -t vscode visualstudio
python gitignore.py -t intellij pycharm
python gitignore.py -t sublime vim

# Operating systems
python gitignore.py -t windows macos linux

# Combined templates
python gitignore.py -t python django vscode
```

### ๐Ÿ›ก๏ธ Smart Duplicate Detection

The script automatically:
- โœ… Reads existing `.gitignore` entries
- โœ… Prevents adding duplicate patterns
- โœ… Preserves comments and formatting
- โœ… Shows informative messages about skipped duplicates

## ๐Ÿ”ง Configuration

### Environment Variables

- `TRACEBACK=1`: Enable detailed error tracebacks

## ๐ŸŽฏ Use Cases

### For New Projects

```bash
# Python project
python gitignore.py -t python

# Node.js project
python gitignore.py -t node

# Full-stack project
python gitignore.py -t python node react vscode
```

### For Existing Projects

```bash
# Add build artifacts
python gitignore.py "build/" "dist/" "*.map"

# Add IDE files
python gitignore.py ".vscode/" ".idea/" "*.swp"

# Add OS-specific files
python gitignore.py -t macos windows linux
```

### Maintenance Tasks

```bash
# Clean up duplicated .gitignore
python gitignore.py --clean

# Preview what would be cleaned
python gitignore.py --clean --preview

# Backup and clean
python gitignore.py --clean  # Creates .gitignore.bak automatically
```

## ๐Ÿ› Troubleshooting

### Common Issues

**Unicode characters not displaying properly**
- Ensure your terminal supports UTF-8 encoding
- On Windows, try using Windows Terminal or enable UTF-8 support

**Permission errors**
- Make sure you have write permissions in the target directory
- Run with appropriate privileges if needed

**Template fetch failures**
- Check your internet connection
- Verify template names are correct (see gitignore.io)

### Debug Mode

Enable detailed tracebacks:

```bash
export TRACEBACK=1  # Linux/Mac
set TRACEBACK=1     # Windows
python gitignore.py [options]
```

## ๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

### Development Setup

```bash
git clone https://github.com/cumulus13/gitignore.git
cd gitignore
pip install rich
```

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- [gitignore.io](https://gitignore.io) for providing the template API
- [Rich](https://github.com/Textualize/rich) for beautiful terminal output
- The Python community for inspiration and support

## ๐Ÿ“ž Support

- ๐Ÿ› **Bug Reports**: [GitHub Issues](https://github.com/cumulus13/gitignore/issues)
- ๐Ÿ’ก **Feature Requests**: [GitHub Issues](https://github.com/cumulus13/gitignore/issues)
- ๐Ÿ“ง **Email**: cumulus13@gmail.com

---

## Author
<div align="center">

**Made with โค๏ธ by [Hadi Cahyadi](https://github.com/cumulus13)**

โญ **Star this repo if you find it helpful!** โญ

</div>

## License

MIT License. See [LICENSE](LICENSE).

## Coffee

[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)

[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)

[Support me on Patreon](https://www.patreon.com/cumulus13)

[Medium](https://medium.com/@cumulus13/gitign-the-smart-gitignore-generator-that-every-developer-needs-d9bd9b23a719)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cumulus13/gitignore",
    "name": "gitign",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "gitignore gitignore.io rich terminal",
    "author": "Hadi Cahyadi",
    "author_email": "cumulus13@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/60/5e/ec9abe202c576cae197003e4460419e5e1ad3f0d80451577b4d60a969a52/gitign-0.17.tar.gz",
    "platform": null,
    "description": "# \ud83d\ude80 GitIgnore Generator\r\n\r\nA powerful and user-friendly Python script to generate `.gitignore` files with default entries, custom patterns, or templates from [gitignore.io](https://gitignore.io). Features rich console output and smart duplicate detection.\r\n\r\n## \u2728 Features\r\n\r\n- \ud83c\udfaf **Smart Generation**: Create `.gitignore` files with sensible defaults\r\n- \ud83d\udd04 **Template Support**: Fetch templates from gitignore.io for popular frameworks\r\n- \ud83d\udee1\ufe0f **Duplicate Prevention**: Automatically detects and prevents duplicate entries\r\n- \ud83e\uddf9 **Cleanup Tool**: Remove duplicates from existing `.gitignore` files\r\n- \ud83d\udcd6 **Syntax Highlighting**: Beautiful syntax-highlighted file reading\r\n- \ud83c\udfa8 **Rich Console Output**: Colorful and informative terminal interface\r\n- \u26a1 **Auto-Append Mode**: Intelligently appends to existing files\r\n- \ud83d\udcbe **Backup Support**: Creates backups when cleaning files\r\n\r\n## \ud83d\udccb Requirements\r\n\r\n- Python 3.6+\r\n- Rich library (`pip install rich`)\r\n\r\n## \ud83d\udd27 Installation\r\n\r\n1. Clone or download the script:\r\n```bash\r\ngit clone https://github.com/cumulus13/gitignore.git\r\ncd gitignore\r\n```\r\n\r\n2. Install dependencies:\r\n```bash\r\npip install rich\r\n```\r\n\r\n3. Make the script executable (optional):\r\n```bash\r\nchmod +x gitignore.py\r\n```\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Basic Usage\r\n\r\n```bash\r\n# Generate .gitignore with default entries\r\npython gitignore.py\r\n\r\n# Add custom entries (auto-appends if file exists)\r\npython gitignore.py \"*.log\" \"temp/\" \"config.local\"\r\n\r\n# Use templates from gitignore.io\r\npython gitignore.py -t python node react\r\n\r\n# Read existing .gitignore with syntax highlighting\r\npython gitignore.py -r\r\n```\r\n\r\n## \ud83d\udcd6 Usage Examples\r\n\r\n### \ud83c\udfaf Creating New .gitignore Files\r\n\r\n```bash\r\n# Basic generation with defaults\r\npython gitignore.py\r\n\r\n# Generate with custom entries\r\npython gitignore.py \"*.tmp\" \"debug.log\" \"*.cache\"\r\n\r\n# Generate with templates\r\npython gitignore.py -t python django\r\n\r\n# Generate without default entries\r\npython gitignore.py --no-defaults -t python\r\n\r\n# Force overwrite existing file\r\npython gitignore.py -f \"*.backup\"\r\n```\r\n\r\n### \ud83d\udcdd Adding to Existing Files\r\n\r\n```bash\r\n# Auto-append mode (detects existing file)\r\npython gitignore.py \"new_pattern\" \"*.local\"\r\n\r\n# Explicit append mode\r\npython gitignore.py -a \"build/\" \"dist/\"\r\n\r\n# Add multiple entries with different separators\r\npython gitignore.py \"file1,file2;file3|file4\"\r\n```\r\n\r\n### \ud83e\uddf9 Cleaning Duplicates\r\n\r\n```bash\r\n# Preview duplicates without changes\r\npython gitignore.py --clean --preview\r\n\r\n# Remove duplicates (creates backup by default)\r\npython gitignore.py --clean\r\n\r\n# Remove duplicates without backup\r\npython gitignore.py --clean --no-backup\r\n\r\n# Clean file in specific directory\r\npython gitignore.py --clean -p /path/to/project\r\n```\r\n\r\n### \ud83d\udcd6 Reading Files\r\n\r\n```bash\r\n# Read .gitignore with syntax highlighting\r\npython gitignore.py -r\r\n\r\n# Read from specific directory\r\npython gitignore.py -r -p /path/to/project\r\n```\r\n\r\n## \u2699\ufe0f Command Line Options\r\n\r\n### Main Options\r\n\r\n| Option | Short | Description |\r\n|--------|-------|-------------|\r\n| `--path` | `-p` | Target directory path (default: current directory) |\r\n| `--data` | `-d` | Additional entries (can be repeated) |\r\n| `--template` | `-t` | Templates from gitignore.io |\r\n| `--append` | `-a` | Append to existing file without overwrite |\r\n| `--force` | `-f` | Skip confirmation prompt |\r\n| `--no-defaults` |  | Don't include default entries |\r\n| `--read` | `-r` | Read and display .gitignore content |\r\n| `--version` | `-v` | Show version information |\r\n\r\n### Cleaning Options\r\n\r\n| Option | Description |\r\n|--------|-------------|\r\n| `--clean` | Clean duplicate entries |\r\n| `--preview` | Preview changes without applying |\r\n| `--no-backup` | Don't create backup file |\r\n\r\n## \ud83c\udfa8 Default Entries\r\n\r\nThe script includes these default entries by default:\r\n\r\n```gitignore\r\n*.pyc\r\n*.bak\r\n*.zip\r\n*.rar\r\n*.7z\r\n*.mp3\r\n*.wav\r\n*.sublime-workspace\r\n.hg/\r\nbuild/\r\n*.hgignore\r\n*.hgtags\r\n*dist/\r\n*.egg-info/\r\ntraceback.log\r\n__pycache__/\r\n*.log\r\n```\r\n\r\n## \ud83c\udf1f Advanced Features\r\n\r\n### \ud83d\udcdd Multiple Entry Formats\r\n\r\nThe script supports various entry formats:\r\n\r\n```bash\r\n# Comma-separated\r\npython gitignore.py \"file1,file2,file3\"\r\n\r\n# Space-separated (use quotes)\r\npython gitignore.py \"file1 file2 file3\"\r\n\r\n# Semicolon-separated\r\npython gitignore.py \"file1;file2;file3\"\r\n\r\n# Array-like format\r\npython gitignore.py \"[file1,file2,file3]\"\r\n\r\n# Quoted entries\r\npython gitignore.py '\"special file.txt\"' \"'another file.log'\"\r\n```\r\n\r\n### \ud83d\udd04 Template Examples\r\n\r\nPopular templates available from gitignore.io:\r\n\r\n```bash\r\n# Programming languages\r\npython gitignore.py -t python\r\npython gitignore.py -t node javascript\r\npython gitignore.py -t java maven\r\npython gitignore.py -t csharp dotnetcore\r\n\r\n# Frameworks\r\npython gitignore.py -t react vue angular\r\npython gitignore.py -t django flask\r\npython gitignore.py -t rails laravel\r\n\r\n# IDEs and editors\r\npython gitignore.py -t vscode visualstudio\r\npython gitignore.py -t intellij pycharm\r\npython gitignore.py -t sublime vim\r\n\r\n# Operating systems\r\npython gitignore.py -t windows macos linux\r\n\r\n# Combined templates\r\npython gitignore.py -t python django vscode\r\n```\r\n\r\n### \ud83d\udee1\ufe0f Smart Duplicate Detection\r\n\r\nThe script automatically:\r\n- \u2705 Reads existing `.gitignore` entries\r\n- \u2705 Prevents adding duplicate patterns\r\n- \u2705 Preserves comments and formatting\r\n- \u2705 Shows informative messages about skipped duplicates\r\n\r\n## \ud83d\udd27 Configuration\r\n\r\n### Environment Variables\r\n\r\n- `TRACEBACK=1`: Enable detailed error tracebacks\r\n\r\n## \ud83c\udfaf Use Cases\r\n\r\n### For New Projects\r\n\r\n```bash\r\n# Python project\r\npython gitignore.py -t python\r\n\r\n# Node.js project\r\npython gitignore.py -t node\r\n\r\n# Full-stack project\r\npython gitignore.py -t python node react vscode\r\n```\r\n\r\n### For Existing Projects\r\n\r\n```bash\r\n# Add build artifacts\r\npython gitignore.py \"build/\" \"dist/\" \"*.map\"\r\n\r\n# Add IDE files\r\npython gitignore.py \".vscode/\" \".idea/\" \"*.swp\"\r\n\r\n# Add OS-specific files\r\npython gitignore.py -t macos windows linux\r\n```\r\n\r\n### Maintenance Tasks\r\n\r\n```bash\r\n# Clean up duplicated .gitignore\r\npython gitignore.py --clean\r\n\r\n# Preview what would be cleaned\r\npython gitignore.py --clean --preview\r\n\r\n# Backup and clean\r\npython gitignore.py --clean  # Creates .gitignore.bak automatically\r\n```\r\n\r\n## \ud83d\udc1b Troubleshooting\r\n\r\n### Common Issues\r\n\r\n**Unicode characters not displaying properly**\r\n- Ensure your terminal supports UTF-8 encoding\r\n- On Windows, try using Windows Terminal or enable UTF-8 support\r\n\r\n**Permission errors**\r\n- Make sure you have write permissions in the target directory\r\n- Run with appropriate privileges if needed\r\n\r\n**Template fetch failures**\r\n- Check your internet connection\r\n- Verify template names are correct (see gitignore.io)\r\n\r\n### Debug Mode\r\n\r\nEnable detailed tracebacks:\r\n\r\n```bash\r\nexport TRACEBACK=1  # Linux/Mac\r\nset TRACEBACK=1     # Windows\r\npython gitignore.py [options]\r\n```\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n### Development Setup\r\n\r\n```bash\r\ngit clone https://github.com/cumulus13/gitignore.git\r\ncd gitignore\r\npip install rich\r\n```\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83d\ude4f Acknowledgments\r\n\r\n- [gitignore.io](https://gitignore.io) for providing the template API\r\n- [Rich](https://github.com/Textualize/rich) for beautiful terminal output\r\n- The Python community for inspiration and support\r\n\r\n## \ud83d\udcde Support\r\n\r\n- \ud83d\udc1b **Bug Reports**: [GitHub Issues](https://github.com/cumulus13/gitignore/issues)\r\n- \ud83d\udca1 **Feature Requests**: [GitHub Issues](https://github.com/cumulus13/gitignore/issues)\r\n- \ud83d\udce7 **Email**: cumulus13@gmail.com\r\n\r\n---\r\n\r\n## Author\r\n<div align=\"center\">\r\n\r\n**Made with \u2764\ufe0f by [Hadi Cahyadi](https://github.com/cumulus13)**\r\n\r\n\u2b50 **Star this repo if you find it helpful!** \u2b50\r\n\r\n</div>\r\n\r\n## License\r\n\r\nMIT License. See [LICENSE](LICENSE).\r\n\r\n## Coffee\r\n\r\n[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)\r\n\r\n[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)\r\n\r\n[Support me on Patreon](https://www.patreon.com/cumulus13)\r\n\r\n[Medium](https://medium.com/@cumulus13/gitign-the-smart-gitignore-generator-that-every-developer-needs-d9bd9b23a719)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A powerful and user-friendly Python script to generate `.gitignore` files with default entries, custom patterns, or templates from gitignore.io",
    "version": "0.17",
    "project_urls": {
        "Bug Tracker": "https://github.com/cumulus13/gitignore/issues",
        "Homepage": "https://github.com/cumulus13/gitignore"
    },
    "split_keywords": [
        "gitignore",
        "gitignore.io",
        "rich",
        "terminal"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aaa6634dfdae67b1c87fdd4c75772e33c962316f9b9f12fba8bc4c0d52489883",
                "md5": "eda8958063fa18de59ed434fa60d90c8",
                "sha256": "5f79b6656c0832589a64187c626223c5f467a13bc4939097e0a4d7de79b5071e"
            },
            "downloads": -1,
            "filename": "gitign-0.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eda8958063fa18de59ed434fa60d90c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10368,
            "upload_time": "2025-08-16T16:50:21",
            "upload_time_iso_8601": "2025-08-16T16:50:21.847917Z",
            "url": "https://files.pythonhosted.org/packages/aa/a6/634dfdae67b1c87fdd4c75772e33c962316f9b9f12fba8bc4c0d52489883/gitign-0.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "605eec9abe202c576cae197003e4460419e5e1ad3f0d80451577b4d60a969a52",
                "md5": "3ef6cac6035a4d8ddd2636fc37ae1ea9",
                "sha256": "ab6a34ae441e8fece858257cb6b9dfd2af9b031c1d790165c749c9c4f4e9b8c2"
            },
            "downloads": -1,
            "filename": "gitign-0.17.tar.gz",
            "has_sig": false,
            "md5_digest": "3ef6cac6035a4d8ddd2636fc37ae1ea9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11208,
            "upload_time": "2025-08-16T16:50:23",
            "upload_time_iso_8601": "2025-08-16T16:50:23.637646Z",
            "url": "https://files.pythonhosted.org/packages/60/5e/ec9abe202c576cae197003e4460419e5e1ad3f0d80451577b4d60a969a52/gitign-0.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-16 16:50:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cumulus13",
    "github_project": "gitignore",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gitign"
}
        
Elapsed time: 1.77665s