로컬 컴퓨터의 내용을 서버와 동기화하려면 rsync를 사용하고, 한 서버에만 배포하는 경우에는 매우 간단합니다 (그리고 Capistrano는 과장입니다.). 나는 ~/.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'
다음, 자식의 repo에서 내 로컬 컴퓨터에. 이 비린내가 보인다면
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을 확인하십시오.
또 다른 옵션은 Git post-receive hook입니다. 하지만 그렇게하려면 서버에 힘내를 설치해야합니다. 또한 보안 & 청결한 이유로 디렉토리 외부에 .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