1

I am working on a Wordpress site, and been given access to the git repository for this project. The entire WP install is in the Repo. All I care about is being able to push my changes to the theme and a select list of plugin folders, ie:

/wp-content/themes/myTheme2017/
/wp-content/plugins/myPlugin1/
/wp-content/plugins/myPlugin2/
....

How can I exclude everything else from being tracked? How can I update my local WP install, and customize my wp-config.php file, and not have those changes be tracked?

As per How do I configure git to ignore some files locally?, I can specify the files I want excluded much like in gitignore files. Then, I can run git update-index --skip-worktree [<file>...] and get my desired results.

git update-index --skip-worktree wp-config.php

The real question is then can I exclude entire folders? Do I have to run the skip-worktree command on every file?

Jeff Wilkerson
  • 376
  • 2
  • 18

1 Answers1

2

The real question is then can I exclude entire folders? Do I have to run the skip-worktree command on every file?

Yes, every file: Git does work with content (files), not containers (directories).

You can find here an approach using submodules

git submodule add -f https://github.com/wp-plugins/wp-migrate-db.git ./wp-content/plugins/wp-migrate-db
git commit -m "Added WP Migrate DB plugin"

That allows to commit separately in your parent repo or your submodule.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250