How to add only all dot files to a git repo? I tried:
$ gitc add .*
fatal: ..: '..' is outside repository
Also, how to add only all dot directories recursively in git, except for .mozilla?
CodePudding user response:
This is best handled with a .gitignore, then you can safely use git add .
.
It can be simplest to write it inside out: ignore everything, then unignore selectively.
/*/
!/.*/
!.gitignore
/.mozilla/
- Ignore everything at the top level.
- Unignore top level directories which start with a dot.
- Unignore any .gitignore files.
- Unignore a top level .mozilla directory.
Here's a test directory.
.
├── .gitignore
├── .mozilla
│ └── no
├── .no
├── .yes
│ ├── .gitignore
│ ├── .mozilla
│ ├── .yes
│ └── yes
└── no
And here is what git add .
sees.
new file: .gitignore
new file: .yes/.gitignore
new file: .yes/.mozilla
new file: .yes/.yes
new file: .yes/yes