Deploy a project using Git push

后端 未结 19 892
囚心锁ツ
囚心锁ツ 2020-11-22 07:06

Is it possible to deploy a website using git push? I have a hunch it has something to do with using git hooks to perform a git reset --hard on the

19条回答
  •  有刺的猬
    2020-11-22 08:04

    Update: I'm now using Lloyd Moore solution with the key agent ssh -A .... Pushing to a main repo and then pulling from it in parallel from all your machines is a bit faster and requires less setup on those machines.


    Not seeing this solution here. just push via ssh if git is installed on the server.

    You'll need the following entry in your local .git/config

    [remote "amazon"]
        url = amazon:/path/to/project.git
        fetch = +refs/heads/*:refs/remotes/amazon/*
    

    But hey, whats that with amazon:? In your local ~/.ssh/config you'll need to add the following entry:

    Host amazon
        Hostname 
        User 
        IdentityFile ~/.ssh/amazon-private-key
    

    now you can call

    git push amazon master
    ssh @ 'cd /path/to/project && git pull'
    

    (BTW: /path/to/project.git is different to the actual working directory /path/to/project)

提交回复
热议问题