开发者

git windows post pull

I have recently converted from svn. My server is under Windows (don't blame me, it wasn't my choice :}

I have created a repo with two branches "master" and "stable".

On my server I want to get files from stable branch.

I have done:

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

Previously I had a .bat script

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

and it worked, now with git

开发者_Go百科
cd my_repo_dir
git pull
echo APPLICATION_STAGE = 'production' > conf\__init__.py
net stop apache2.2
net start apache2.2

nothing is executing after git pull, whether it is successful, or up-to-date. It just exits to prompt with no warning.

I thought about hooks. I have created:

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

both files with the same contents:

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

and nope, it is not executing either... Maybe I am missing interpreted declaration line (#!/bin/sh on *nix) but I am not sure what it is on windows...


Few points:

  • Make sure you have git.exe on path. Do a where git and you must get something like

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

    If git.cmd is being used ( from C:\Program Files (x86)\Git\cmd\git.cmd ), you have to do call git pull for it to continue execution. I would say add git.exe to path and start using it.

  • Even on Windows, you must have the shebang - #!/bin/sh for the hooks to properly run.

  • If you want a hook to run on pull, you probably want to use the post-merge hook. post-receive and post-update run on remote repos when you push to them.


git is probably a batch wrapper around the real executable. Use call git pull.

And those hooks only fire when content is pushed from a remote location, as far as I can tell from the documentation. So they're ignored for pull.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜