Git ignore everything except custom theme directory

I only just started trying to use GitHub with WordPress, so I'm completely new to everything git.

My problem is simple: I want to setup my .gitignore so git ignores absolutely everything except my Wordpress theme which is located at a custom directory '/goods/themes/my-wordpress-theme'.

I've tried a variety of .gitignore files such similar to the following and nothing works.

# Ignore everything
*

# Except 'my-wordpress-theme'
!goods/themes/my-wordpress-theme/*

I'm running Ubuntu with git version 2.7.4

Please help! Thanks, Asher.

Topic github git theme-development Wordpress

Category Web


Run ignore on your themes directory and check out your themes to their individual directories. That will keep your theme segmented just as your WordPress environment. There is no sense in checking out a root git for a single theme.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.