Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Created August 1, 2012 12:47
Show Gist options
  • Save AmyStephen/3226542 to your computer and use it in GitHub Desktop.
Save AmyStephen/3226542 to your computer and use it in GitHub Desktop.
To create a .gitignore with a list of all files in Repository
<?php
/**
* @package Molajo
* @copyright 2012 Amy Stephen. All rights reserved.
* @license GNU GPL v 2, or later and MIT, see License folder
*
* Place in the root of your website - execute it - and copy the results into your .gitignore
*/
$current_path = __DIR__;
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($current_path),
RecursiveIteratorIterator::SELF_FIRST);
foreach($objects as $name => $object){
if($object->isDir()) {
$dirRead = dir($name);
$path = $dirRead->path;
while (false !== ($entry = $dirRead->read())) {
if (is_dir($path . '/' . $entry)) {
} else {
$item = $path . '/' . $entry . '<br />';
echo substr($item, strlen($current_path) + 1, 99999);
}
}
$dirRead->close();
}
}
/** Current */
$dirRead = dir(__DIR__);
$path = $dirRead->path;
while (false !== ($entry = $dirRead->read())) {
if (is_dir($path . '/' . $entry)) {
} else {
$item = $path . '/' . $entry . '<br />';
echo substr($item, strlen($current_path) + 1, 99999);
}
}
$dirRead->close();
@AmyStephen
Copy link
Author

Copy this file to the root of the website and execute it from a browser.

Copy the list into a gitignore file to have a complete list of all files in the primary repository that should be ignored during development of extensions.

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