Skip to main content

🛡️ Protect files from accidental Git commits

Project description

🛡️ NoStage

PyPI version Python versions License: MIT

Protect files from accidental Git commits

NoStage is a lightweight CLI tool that automatically unstages protected files when you commit, perfect for temporary debug files, experimental code, and personal workflow files that you don't want in your remote repository.

🎥 Demo

NoStage Demo

See NoStage in action!

🎯 Why NoStage?

Ever had this happen?

# You're debugging with some test files
$ ls
debug.js  test-output.txt  my-feature.js  ...

# You finish your work and commit everything
$ git add .
$ git commit -m "Add new feature"

# 😱 Oops! debug.js and test-output.txt are now committed!

NoStage solves this. Mark files as "protected" once, and they'll never be accidentally committed.

🆚 NoStage vs .gitignore

Feature .gitignore NoStage
Scope Team-wide, affects everyone Personal, per-developer
Already tracked files ❌ Can't ignore ✅ Works on any file
Use case Files that should NEVER be committed Files you might commit LATER
Setup Manual editing Simple CLI commands
Dynamic Static file Easy add/remove on the fly

Perfect for:

  • 🐛 Debug/test files you create while developing
  • 🧪 Experimental code you're not ready to commit
  • 📝 Personal notes or scratch files
  • 🔧 Local configuration tweaks

🚀 Installation

# Install via pip
pip install nostage

# Initialize in your git repository
cd your-project
nostage init

📖 Usage

Protect Files

# Protect specific files
nostage add debug.js test-output.txt scratch.py

# Now commit normally - protected files are auto-unstaged!
git add .
git commit -m "my changes"
# ✅ debug.js, test-output.txt, scratch.py won't be committed

Protect Patterns

# Protect all files matching a pattern
nostage pattern "*.temp.js"
nostage pattern "debug_*.py"
nostage pattern "scratch/*"

Manage Protection

# List all protected files and patterns
nostage list

# Remove protection from a file
nostage remove debug.js

# Remove a pattern
nostage remove-pattern "*.temp.js"

# Check status
nostage status

🎬 How It Works

  1. You mark files for protection:

    nostage add debug.js
    
  2. NoStage installs a git pre-commit hook that runs automatically

  3. When you commit:

    git add .
    git commit -m "update"
    
  4. Protected files are auto-unstaged:

    🛡️  NoStage: Protecting 1 file(s) from commit:
       • debug.js
    
  5. Only your real work gets committed!

💡 Examples

Scenario 1: Debugging

# You create a debug file
echo "console.log('debug')" > debug.js

# Protect it so you don't accidentally commit it
nostage add debug.js

# Work on your feature
vim feature.js

# Commit everything - debug.js is automatically protected!
git add .
git commit -m "Add feature"

Scenario 2: Experimental Code

# Protect experimental files
nostage add experiment.py
nostage pattern "test_*.py"

# Experiment freely
# When ready, remove protection and commit
nostage remove experiment.py
git add experiment.py
git commit -m "Add new algorithm"

Scenario 3: Team Project

# Each developer can protect their own files
# Alice protects her debug scripts
nostage add alice-debug.sh

# Bob protects his test data
nostage add test-data.json

# No .gitignore conflicts, everyone's happy! 🎉

🛠️ Commands

Command Description
nostage init Install NoStage hook in current repo
nostage add <files...> Protect specific files
nostage remove <files...> Unprotect specific files
nostage pattern <pattern> Protect files matching pattern
nostage remove-pattern <pattern> Remove pattern protection
nostage list Show all protected files/patterns
nostage status Show NoStage status
nostage uninstall Remove NoStage hook

💡 Tip: Run nostage --help for detailed usage information.

⚙️ Requirements

  • Python 3.7+
  • Git

📁 The .nostage File

NoStage stores your protected files and patterns in a .nostage file in your repository root. Since this is for personal use, add it to your .gitignore:

echo ".nostage" >> .gitignore

❓ FAQ

Q: Does NoStage prevent files from being staged?

No. Files are staged normally with git add. NoStage uses a pre-commit hook that automatically unstages protected files right before the commit is finalized. The end result: protected files never make it into your commits.

Q: What if I have an existing pre-commit hook?

NoStage will detect existing hooks and append its logic. Your existing hooks will continue to work.

Q: Can I temporarily commit a protected file?

Yes! Simply remove protection, commit, then re-add protection:

nostage remove debug.js
git add debug.js && git commit -m "Add debug.js"
nostage add debug.js
Q: What happens when I run `nostage uninstall`?

It removes the pre-commit hook. Your .nostage file remains intact, so you can reinstall anytime with nostage init.

Q: How do I uninstall NoStage?

Just run:

pip uninstall nostage

That's it! The hook will automatically clean itself up (and remove the .nostage file) on your next commit.

For immediate cleanup (optional):

nostage uninstall  # Removes hook and .nostage immediately
pip uninstall nostage

🤝 Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests

📝 License

MIT License - feel free to use in your projects!

🌟 Show Your Support

If NoStage helps you, give it a ⭐ on GitHub!


Made with ❤️ by developers who've accidentally committed debug files one too many times.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostage-0.1.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nostage-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file nostage-0.1.1.tar.gz.

File metadata

  • Download URL: nostage-0.1.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for nostage-0.1.1.tar.gz
Algorithm Hash digest
SHA256 945dcc66e2ea986f6d5e28b5ac96fe923aaa91446ec2752db55e895bcdfede5c
MD5 71307533530d31b55a59a1abb7a7abc3
BLAKE2b-256 85faa38a3ce7af1efca3a6947617389b5e0f4e42ee63cf1cc953e9e98a35ba34

See more details on using hashes here.

File details

Details for the file nostage-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nostage-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for nostage-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9c252065f93d78054c8e5f240f3291e8fb1a915e9d315e8805cc7d731949674
MD5 287e36ff505c9812692b43c167bbeae6
BLAKE2b-256 9320f817824cf123c91907ddc54081108a62a3a00f302dbf6ec0dd7467e1c159

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page