Switch between git contexts easily for different environments (personal, work, client projects, etc.) using Git's conditional includes.
- Guides you through creating multiple context-specific configurations
- Automatically organizes the configs in your global .gitconfig file
- Supports any number of different contexts (personal, work, client1, client2, etc.)
- Each context gets its own configuration file
- Uses git's conditional includes based on repository paths
- Automatically applies the right identity based on where your repositories are located
- Automatically detect the appropriate context based on repository remote URLs
- Match GitHub, GitLab, or any git hosting provider with flexible pattern matching
- Supports both HTTPS and SSH remote URL formats
- Quickly create new contexts using predefined templates
- Built-in templates for common scenarios (personal, work, client projects, open source)
- Auto-configure URL patterns for easier setup
- Share context configurations between machines or team members
- Export your contexts to a single JSON file
- Import contexts from a shared configuration file
- Creates a
.gitconfig.d
directory to organize your context-specific configs - Backs up your existing configuration before making changes
- Handles existing conditional includes safely
The easiest way to install Git Context Switcher:
# Install globally for command-line use
npm install -g git-context-switcher
# After installation, you can use the command from anywhere
git-context --version
# Clone the repository
git clone https://github.com/befreestudios-io/git-context-switcher.git
cd git-context-switcher
# Install dependencies
npm install
# Make the script executable
chmod +x index.js
# Create a global symlink to use the command anywhere
npm link
Run the interactive setup wizard to configure your git contexts:
git-context setup
The wizard will:
- Create a
.gitconfig.d
directory in your home folder - Back up your existing git config
- Guide you through setting up multiple contexts
- Update your main
.gitconfig
with conditional includes
Once set up, Git will automatically use the correct identity based on your repository location. You can also use these commands:
# List all your configured contexts
git-context list
# Check which context applies to the current directory
git-context apply
# Add a new context
git-context add
For more detailed information, please see the following documentation:
- Command Reference - Complete reference for all commands and options
- Usage Examples - Detailed examples showing common use cases
- How It Works - Technical explanation of how the tool works
- Troubleshooting - Solutions for common issues
Git Context Switcher follows Semantic Versioning. For the versions available, see the tags on this repository or check the CHANGELOG.md file.
For maintainers and contributors looking to release new versions, please see our Release Process documentation.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please make sure your code follows the existing style and passes all tests.
For more information about our development process, coding standards, and CI/CD pipeline, see our Contributing Guidelines.
For security issues, please see our Security Policy.