开发者

bash script to synchronize directories but ignoring certain files

开发者 https://www.devze.com 2023-01-26 01:53 出处:网络
I\'m trying to come up with a solution for working on my PhoneGap projects. At the moment I\'m developing in one folder and then copying over the edited files into the www folder of xcode - so I can k

I'm trying to come up with a solution for working on my PhoneGap projects. At the moment I'm developing in one folder and then copying over the edited files into the www folder of xcode - so I can keep a git repo separate to what gets built. This is becoming very repetitive and I want to automate it开发者_如何学Python. Any ideas? Basically it needs to ignore .git, .project and other dot files. I'm on mac osx.


That's easy to do with rsync. Check the --exclude options in the manual page.


If this is in a git repo, you could also just use git archive to bundle things up - that has the benefit of looking only at tracked content, and being able to operate on an arbitrary commit, not just what you have in your work tree at the moment.

If there are tracked files you don't want to archive, you can exclude them using the export-ignore gitattribute. For example:

 $ cat .gitattributes
 .project export-ignore
 .gitignore export-ignore
 .gitattributes export-ignore

Just like .gitignores, you can have .gitattributes in subdirectories as well, and you can use patterns. For example, those last two could be simplified into .git*.

Note that git-archive will by default use the attributes from the commit/tree you're archiving, not the working tree, so if you're fiddling with your attributes and testing, you'll want to use git archive --worktree-attributes.


you can use rsync which is meant for synchronizing directories & can also be configured to have some pattern matching for including & or excluding files from the sync.

0

精彩评论

暂无评论...
验证码 换一张
取 消