问题:
My issue is that I have a bunch of WordPress websites in my git repo, of which I want to selectively commit only the content of my themes
folders, while ignoring the rest of the redundant files found in WordPress.我的问题是我的 git 存储库中有一堆 WordPress 网站,其中我想有选择地只提交我的themes
文件夹的内容,而忽略在 WordPress 中找到的其余冗余文件。
I've used .gitignore files to ignore file types before, but can it be used the other way around- that is to ignore everything BUT a certain folder path?我之前使用过 .gitignore 文件来忽略文件类型,但是可以反过来使用它 - 即忽略除某个文件夹路径之外的所有内容吗?
root (git repo)根(git repo)
- / wordpress - / wordpress
- - / (WordPress Site 1)/wp-content/themes - - / (WordPress 站点 1)/wp-content/themes
- - / (WordPress Site 2)/wp-content/themes - - / (WordPress 站点 2)/wp-content/themes
- - / (WordPress Site 3)/wp-content/themes - - / (WordPress 站点 3)/wp-content/themes
Thanks-谢谢-
UPDATE:更新:
Based on the answers I did the following, but it's not working.根据答案,我做了以下操作,但它不起作用。 Any ideas?有任何想法吗?
# Ignore everything:
*
# Except for wordpress themes:
!*/wp-content/themes/*
I've also tried the following variations:我还尝试了以下变体:
!*/wp-content/themes*
!*wp-content/themes/*
!wp-content/themes/*
!/wordpress/*/wp-content/themes*
!wordpress/*/wp-content/themes*
None of these read my themes
folders.这些都没有读取我的themes
文件夹。
解决方案:
参考一: https://en.stackoom.com/question/Lzae参考二: https://stackoom.com/question/Lzae