Skip to content

Remzi1993/pwsh-gitignore-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pwsh-gitignore-template

MIT License

PowerShell 7+ script that silently drops a .gitignore into every new repo right after git init. Handles git init <dir>, multiple -C flags, and skips --bare. Never overwrites an existing file.


✨ Features

  • Zero-friction: keep using git init as usual
  • Silent by default; optional DEBUG and diagnostics
  • Cross-platform in PowerShell 7+ (Windows/macOS/Linux)

πŸ”§ Requirements

  • PowerShell 7+
  • Git on PATH

πŸ› οΈ Installation

  1. Open your profile and paste the script at the end (after any modules).
    notepad $PROFILE β†’ paste β†’ save Reload: . $PROFILE
  2. Create a template (one-time):
    • Put a file at $HOME\.git-templates\.gitignore, or
    • Run: New-GitIgnoreTemplate -UseGitConfig -SetEnvironment

πŸš€ Usage

  • Standard: git init
  • Target dir: git init MyRepo
  • With -C: git -C C:\work init
  • Bare repos are skipped: git init --bare Repo.git

The script never overwrites an existing .gitignore. To overwrite manually: Copy-GitIgnoreFromTemplate -WorkTree . -Force

πŸ” Diagnostics (optional)

  • Toggle debug: $Global:GIT_INIT_WRAPPER_DEBUG = $true
  • Show search order and the picked template: Show-GitIgnoreTemplatePaths

πŸ“¦ Built-ins

  • New-GitIgnoreTemplate [-UseGitConfig] [-SetEnvironment] [-Path <file>]
  • Get-GitIgnoreTemplatePaths [-Refresh]
  • Show-GitIgnoreTemplatePaths
  • Copy-GitIgnoreFromTemplate -WorkTree <dir> [-Force]

🀝 Contributing

  1. Fork β†’ branch β†’ PR
  2. Keep changes minimal and well-commented
  3. Add/update tests/instructions if behavior changes

πŸ“„ License

This project is licensed under the MIT License

About

PowerShell 7+ script that silently drops a .gitignore into every new repo right after git init

Resources

License

Stars

Watchers

Forks