Skip to content

Instantly share code, notes, and snippets.

@eriktdesign
Created September 23, 2021 17:42
Show Gist options
  • Save eriktdesign/fd19ae1930c8de7f33a770f917ab2002 to your computer and use it in GitHub Desktop.
Save eriktdesign/fd19ae1930c8de7f33a770f917ab2002 to your computer and use it in GitHub Desktop.
Generate a .gitignore file based on WP Engine's WordPress .gitignore
#!/bin/bash
if [ "$1" != "" ]; then
theme_name=$1
fi
FILE=.gitignore
if test -f "$FILE"; then
echo ".gitignore exists, aborting."
else
curl https://wpengine.com/wp-content/uploads/2013/10/recommended-gitignore-no-wp.txt -o .gitignore
echo "Wrote new .gitignore"
echo "
# Plugins
wp-content/plugins/*
wp-content/plugins/**/" >> .gitignore
echo "Excluded plugins"
if [ theme_name != "" ]; then
echo "
# Themes
wp-content/themes/**/
!wp-content/themes/$theme_name/
!wp-content/themes/$theme_name/*
!wp-content/themes/$theme_name/**/*" >> .gitignore
echo "Included theme: $theme_name"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment