Remote machine
$ MKDIR/WWW/TEACHERAPI # Create working directory
$ cd/data/git
$ git init teacherapi.git--bare--shared
Initialized empty shared Git repository in/data/git/teacherapi.git/
$ CD teacherapi.git/
$ vi hooks/post-receive # or use cat > hooks/post-receive to create and type the following code, and finally Ctrl+d save the exit,
#!/bin/sh
Git_work_tree=/www/teacherapi git checkout-f <branch> # default Master Branch
$ chmod +x hooks/post-receive # Set executable permissions
You can also use the following code snippet
$ cd git
$ mkdir Somesite.git
$ CD somesite.git/
$ git init--bare
Initialized Empty Git repository in/home/caius/git/somesite.git/
$ git--bare update-server-info
$ git config core.worktree/home/caius/vhosts/somesite.com/htdocs
$ git config core.bare false
$ git config receive.denycurrentbranch ignore
$ cat > Hooks/post-receive
#!/bin/sh
Git checkout-f
^d
$ chmod +x hooks/post-receive
Execute script after work tree update is complete
$ cd/gitpah/hooks/
$ VI post-checkout #创建post-checkout Type the following code, and when the ' git-checkout ' command finishes updating the entire work tree (worktree), the hook is called
#!/bin/sh
/etc/init.d/teacherapitest.tbkt.cn restart
$ chmod +x post-checkout
Local Machine
$ git clone ssh://[email protected]:6022/data/git/teacherapi.git
$ CD teacherapi/
$ Echo ' Hello, world! ' > index.html
$ git add index.html
$ git commit-m "init project"
$ GIT push origin Master:master
Add a remote repository
$ git remote add 106 ssh://[email Protected]:6022/opt/gitdata/chsy_cms.git
Error during remote push: cannot run hooks/post-receive:no such file or directory
In addition to checking the contents of the Post-receive file, also look at the file format right, using the $ cat-a hook/post-receive view
Document Content Reference:
Http://caiustheory.com/automatically-deploying-website-from-remote-git-repository
Http://toroid.org/ams/git-website-howto
More Hooks Usage: http://www.360doc.com/content/12/1012/11/10140166_241004726.shtml
GIT uses hooks to push directly to the working directory