2011-06-09 108 views
1

我最近从svn转换而来。 我的服务器是Windows下(不要怪我,这是不是我的选择:}git windows post pull

我创建了一个回购有两个分支“主”和“稳定”

在我的服务器我想要的。 。从稳定分支获得文件

我做:

git clone git://url/.git src 
cd src 
git checkout --track -b stable origin/stable 

以前我有一个蝙蝠脚本

cd my_repo_dir 
svn update 
echo APPLICATION_STAGE = 'production' > conf\__init__.py 
net stop apache2.2 
net start apache2.2 

和它的工作,现在用git

cd my_repo_dir 
git pull 
echo APPLICATION_STAGE = 'production' > conf\__init__.py 
net stop apache2.2 
net start apache2.2 

没有什么混帐拉后执行,无论是成功,还是先进的日期。 它只是退出提示没有任何警告。

我想过挂钩。 我已经创建:

.git/hooks/post-receive 
.git/hooks/post-update 

两个文件具有相同的内容:

echo APPLICATION_STAGE = 'production' > conf\__init__.py 
net stop apache2.2 
net start apache2.2 

和不,它不执行要么... 也许我缺少解释报关行(#/ bin中!/sh on * nix) 但我不确定它是什么在windows上...

回答

3

几点:

  • 确保您已在路径git.exe。做一个where git并且如果使用git.cmd必须得到类似

    C:\Program Files (x86)\Git\bin\git.exe 
    

    (从C:\ Program Files文件(x86)的\的Git \ CMD \ git.cmd),你必须为它做call git pull继续执行。我会说增加git.exe到路径并开始使用它。

  • 即使在Windows上,您也必须拥有shebang - #!/bin/sh以便挂钩正常运行。

  • 如果你想要一个钩子在pull上运行,你可能想要使用post-merge钩子。 post-receivepost-update在您推送到它们时在远程回购站上运行。

1

git可能是一个真正的可执行文件的批处理包装。使用call git pull

只要从远程位置推送内容,只有从文档中可以看出这些挂钩才会触发。所以他们被忽略了pull