osx - Implement .gitignore behavior in a shell script? -
i'm writing shell script syncs files , want give users ability exclude files syncing creating .syncignore
file similar git's .gitignore
file. according gitignore documentation, , own experiments, these exclusion rules more complicated simple glob match. examples:
- if have
foo
in.gitignore
file, excludefoo
appearing anywhere in path (e.g../foo
,./bar/foo
, ,./bar/foo/baz
excluded) not partial matches offoo
(e.g../foobar
,./bar/foobar/baz
not excluded). - if include slash, rule applied relative current directory. example, if have
/foo
in.gitignore
file, exclude./foo
not./bar/foo
. - you can include wildcards. example,
foo*
exclude./foo
,./foobar
, ,./bar/foobar/baz
.
is there easy way replicate exclusion rules .gitignore
in shell script on os x?
use
rsync
synchronize files. use existing include/exclude pattern support. put rules in.rsync-filter
, pass-f
flag make read patterns file.just use
git
. make sure have git 2.3.0 or later on both sides, , use push-to-deploy.
Comments
Post a Comment