Deploy a project using Git push

后端 未结 19 1167
囚心锁ツ
囚心锁ツ 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:02

    After many false starts and dead ends, I'm finally able to deploy website code with just "git push remote" thanks to this article.

    The author's post-update script is only one line long and his solution doesn't require .htaccess configuration to hide the Git repo as some others do.

    A couple of stumbling blocks if you're deploying this on an Amazon EC2 instance;

    1) If you use sudo to create the bare destination repository, you have to change the owner of the repo to ec2-user or the push will fail. (Try "chown ec2-user:ec2-user repo.")

    2) The push will fail if you don't pre-configure the location of your amazon-private-key.pem, either in /etc/ssh/ssh_config as an IdentityFile parameter or in ~/.ssh/config using the "[Host] - HostName - IdentityFile - User" layout described here...

    ...HOWEVER if Host is configured in ~/.ssh/config and different than HostName the Git push will fail. (That's probably a Git bug)

提交回复
热议问题