Last active
January 23, 2026 03:02
-
-
Save LordAmit/cda97e185f3641af7830777404d31d8a to your computer and use it in GitHub Desktop.
git-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # put it whereever path. then: | |
| # git config --global alias.ignore '!/Users/<username>/<whereever>/git-ignore' | |
| # Check if a filename was provided | |
| if [ -z "$1" ]; then | |
| echo "Usage: git ignore <filename>" | |
| exit 1 | |
| fi | |
| # Append the filename to .gitignore if it's not already there | |
| if grep -Fxq "$1" .gitignore 2>/dev/null; then | |
| echo "'$1' is already in .gitignore" | |
| else | |
| echo "$1" >> .gitignore | |
| echo "Added '$1' to .gitignore" | |
| fi | |
| # Optional: Stop tracking the file if it's already in the index | |
| git rm --cached "$1" 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment