git钩子同步测试目录

日常开发流程为:开发机->公共仓库->测试,从公共仓库到测试由git钩子来完成,建立过程为:

  1. 建立远程remotehost公共仓库pubrepos:
    • mkdir pubrepos&& cd pubrepos && git –bare init
  2. 将本地开发机仓库push到远程remotehost公共仓库pubrepos:
    • git remote add remotehost user@remotehost:pubrepos
    • git push remotehost master
  3. 建立远程remotehost测试目录testdir,通过sparse checkout只同步需要的目录:
    • mkdir testdir && cd testdir && git init
    • git remote add -f origin pubrepos
    • git config core.sparsecheckout true
    • echo testproject/ >> .git/info/sparse-checkout
    • git pull origin master
  4. 在远程公开仓库pubrepos中添加钩子:
    • cd pubrepos
    • echo -e “pushd testdir \n unset GIT_DIR \n git pull origin master \n popd \n exec git update-server-info” > hooks/post-update
    • chmod u+x hooks/post-update
Advertisements
此条目发表在tools分类目录。将固定链接加入收藏夹。

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s