0

I am trying to create a BASH shell script that runs through SSH on my shared hosting account to automate the git website control system detailed in:

http://danielmiessler.com/study/git/#website.

So far my bash script is right out of the above article:

cd ~/mydomains; mkdir $name.git;
cd ~/mydomains/$name.git; git init --bare; 
/bin/vi ~/domains/$name.git/hooks/post-update

The first 2 lines work as expected.

when I add the third line the script seems to freeze up. the path to vi is /bin/vi in my environment.

Directly from the article I want the to perform the following:

vi /path/website.git/hooks/post-update

then insert:

GIT_WORK_TREE=/path/htdocs git checkout -f

Then close the file.

Could anyone offer me some advice on what to do now?

2
  • 2
    Why do you want to use vi? Does echo 'GIT_WORK_TREE=/path/htdocs git checkout -f' >> /path/website.git/hooks/post-update not suffice? Commented Mar 22, 2013 at 14:12
  • Thanks for looking, I'm not experienced with Bash so just following article step by step Commented Mar 22, 2013 at 14:31

2 Answers 2

3

Why are you try to use vi in script just to add line into file? Problem is that vi is interactive, but you're looking how to automate this ;-)

You should use

echo "GIT_WORK_TREE=/path/htdocs git checkout -f" >> ~/domains/$name.git/hooks/post-update
Sign up to request clarification or add additional context in comments.

3 Comments

-1, this is not an answer to his question, and there is no reason not to use vim.
What this minus is for? His problem isn't with hook, but with script, which makes this hook!
Sorry, my bad. I can't undo my vote, but I will if you make a minor edit to your post.
1

I believe you need to make the hook script executable before git will use it.

chmod +x /path/website.git/hooks/post-update

After that, after pushing, the script ought to be executed.

1 Comment

will do, I believe thats the next line in the article, Regards, Bill

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.