Git windows post pull

I recently converted from svn. My server is under Windows (do not blame me, it was not my choice:}

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

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

I did:

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

I used to have 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

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

nothing is done after git pull, whether it is successful or relevant. It simply exits the command line without warning.

I was thinking about hooks. I 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 no, it doesn't execute either ... Maybe I miss the interpreted declaration line (#! / Bin / sh on * nix) but I'm not sure if it's on the windows ...

+1
source share
2 answers

A few points:

  • Make sure you have git.exe in the path. Do where git and you should get something like

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

    If you are using git.cmd (from C: \ Program Files (x86) \ Git \ cmd \ git.cmd), you need to call git pull to continue. I would say add git.exe to the path and start using it.

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

  • If you want the hook to work when pressed, you probably want to use the post-merge hook. post-receive and post-update run remote repositories when you click on them.

+3
source

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

And these interceptors only start when the content is removed from a remote location, as far as I can tell from the documentation. Therefore, they are ignored for pull .

+1
source

Source: https://habr.com/ru/post/1444929/


All Articles