Created
October 19, 2015 18:54
-
-
Save SebSept/f74198381e658de259cb to your computer and use it in GitHub Desktop.
tiny php script to add files to .gitignore file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env php | |
<?php | |
/** | |
* add files to .gitignore. | |
* Put this file in your bin dir (/home/<username>/bin/), make it executable (chmod +x /home/<username>/bin/gitingore.php). Done. | |
**/ | |
// remove script name | |
array_shift($argv); | |
// arguments are file name | |
$files = $argv; | |
if (empty($files)) { | |
throw new Exception('Provide files or directories to ignore as arguments.'); | |
} | |
$files_as_string = implode(PHP_EOL, $files).PHP_EOL; | |
if (file_put_contents('.gitignore', $files_as_string, FILE_APPEND)) { | |
print "Files added to .gitignore : $files_as_string"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In terminal you can now type
gitignore vendor/
to add vendor directory to .gitignore file (created if not present).