Skip to content

Instantly share code, notes, and snippets.

@martinec
Last active May 11, 2021 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinec/d14bba04e223283fd932999a53d3357d to your computer and use it in GitHub Desktop.
Save martinec/d14bba04e223283fd932999a53d3357d to your computer and use it in GitHub Desktop.
.gitignore.local for gitignore.io
git config --global alias.ignore-create '!gi() { \
if [ $# -eq 0 ]; then \
echo "Usage: git ignore-create list-item,...\n" ;\
echo "Avalaible list items:" ;\
curl -sL "https://www.gitignore.io/api/list" | tr -d "\n" ;\
echo "" ;\
else \
echo "# DO NOT EDIT THIS FILE" ;\
echo "# Put your local changes on .gitignore.local, then\n" ;\
echo "# To update type: git ignore-update" ;\
echo "# To recreate type: git ignore-create $@\n" ;\
echo "# You only need to install this script once" ;\
echo "# curl -L https://git.io/fjL9q | sh\n" ;\
echo "# script source at https://git.io/fjL9k" > .gitignore ;\
curl -sL "https://www.gitignore.io/api/$@" >> .gitignore ;\
echo "\n\n### LOCAL CHANGES STARTS HERE ###" >> .gitignore ;\
touch .gitignore.local ; cat .gitignore.local >> .gitignore ;\
cat .gitignore ;\
git config --global alias.ignore-update "!gi() { \
git ignore-create $@ ;}; gi" ;\
fi ;\
}; gi'
@martinec
Copy link
Author

martinec commented Apr 1, 2019

git ignore-create | git ignore-update for gitignore.io preserving local changes

To run these commands you need an active internet connection.

  1. You only need to install this script once:
curl -L https://git.io/fjL9q | sh
  1. To print the list of operating systems, programming languages and IDEs, type:
git ignore-create
  1. To create a default .gitignore, type:
git ignore-create linux
  1. You can edit your .gitignore.local to add any local change:
vim .gitignore.local
  1. To update your .gitignore to include the local changes, type:
git ignore-update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment