Terminal: how can I paste a file to all the subfolders within a directory?
# Ignore files below *.class # but not these files !.gitignore
I want to propagate this to all sub-folders or even sub-sub-folders within the directory.
- Remove Git Credential-osxkeychain
- Git Log in ZSH Terminal
- Make bash commands to fall back to git commands if git command exists
- How to shut off localization in git 1.8
- How do I get git to use Textmate as my default editor?
- Moving a Git install on Linux
I know I can do it in the naive way by copying and pasting it manually.
But is there a better way to do this using a few commands in the terminal ?
2 Solutions collect form web for “Terminal: how can I paste a file to all the subfolders within a directory?”
You don’t have to (“propagate this to all sub-folders or even sub-sub-folders within the directory”):
.gitignore rule will be applied to all subfolders, unless another
.gitignore rule (in one of the subfolders) override that rule.
See Pro Git book
Patterns read from a
.gitignorefile in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file.
find . -type d -print | xargs -L 1 cp .gitignore
The find command prints out the name of all directories under . and including .
The xargs command, with the -L 1 parameter, executes
cp .gitignore <dir> for each directory found.
You’ll see an error about not copying .gitignore onto itself in the current directory.