=====
下面的解決辦法,可能只是適用於我遇到的這種情況,又想做鈎子,又想恢復原先老人們配置的git的正常使用。
=====
因為是以前離職的員工配的,所以先檢查一下原來的git能能正常使用不:
1、只有一條分支
master
2、版本庫和項目目錄是同一個,即
git clone root@www.xx.com:/home/project
生產服務器上的項目目錄也是: /home/project
=> 不知道 他們這么配的道理是什么。
3、在生產服務器上,執行 git pull,報告如下錯誤:
remote name from which new revisions should be fetched.
4、配置文件 .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
quotepath = false
[receive]
denyCurrentBranch = ignore
==========================================
解決方案:
1、給項目文件夾的提高權限
chmod -R 777 /home/project
2、修改 .git/config文件
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[receive]
denyCurrentBranch = ignore
denyNonFastForwards = false
3、進入.git/hooks/
=》git鈎子,百度有很多,但可能不適用我這邊的情況。
放入一個 文件,文件名: post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
cd ..
env -i git reset --hard
=======================
結果:
我在本地提交,生產服務器上的項目文件夾里的文件目錄也起變化了,鈎子也成功。