ローカルマシンの内容をサーバと同期させるためにrsyncを使用しています.1台のサーバにデプロイするだけであれば、かなりシンプルになります(そして、カピストラーノは過剰です)。私は~/.bash_profile
で次のエイリアスを置く:
alias eget='rsync -avie ssh [email protected]:sites/example.com/www/ ~/Projects/example/example.com/www/ --exclude .DS_Store --exclude ".git*" --delete-after'
alias edep='rsync -avuie ssh ~/Projects/example/example.com/www/ [email protected]:sites/example.com/www/ --exclude .DS_Store --exclude ".git*" --delay-updates --delete-after'
その後、私のローカルマシン上のgitのレポから。私が行います
git commit -am 'commit some changes'
git pull --rebase # pull any new changes from remote (--rebase prevents an unnecessary merge commit.)
eget -n # confirm which files I've changed
それは魚に見える場合、私は-nなしeget
を行い、その後、ちょうどgit diff -w
を行うことができます。その後、変更を保存したいファイルに対してgit checkout -- path/to/file
を実行できます。その後、私はまだ得られなかったサーバー上の変更をコミットします。これは、サーバー上のファイルが展開とは異なる方法で変更されている場合にのみ発生します。そうしないと、あなたのローカルバージョンは常にサーバー上のファイルよりも最新であるため、あなたのローカルにまだ持っていないサーバー上のものを上書きすることを心配する必要はありません。続き...
edep -n # just see what files will be deployed/updated/etc.
edep # looks good. Deploy for real.
完了!
詳細はrsync(1) Mac OS X Manual Pageをご覧ください。
もう1つの方法はGit post-receive hookです。しかし、これを行うにはサーバーにGitをインストールする必要があります。また、セキュリティ&清潔の理由から、ディレクトリの外に.git
ディレクトリを置くことをお勧めします。 Git core.worktree
設定オプションでこれを行うことができます。たとえば、~/git/example.com.git
からは、git init --bare; git config core.worktree ~/sites/example.com/
となります。これにより、~/git/example.com.git
は~/sites/example.com/
の.git
のようになります。
をチェックアウトhttp://stackoverflow.com/questions/279169/deploy-php-using-git – philfreo
またはCapistrano http://help.github.com/capistrano/ – philfreo