Rails EC2 – Git Remote Hook Not Commiting

I’m trying to connect a remote on Rails to automatically push changes to this EC2. My remote looks like this.

pd ssh and then location ending in /eko_web.git (fetch) 
pd same (fetch)

Pd points towards a bare git repo. It has a post-receive hook:

  • Using cloud-init to clone git repo when launching AWS EC2 instance
  • How to change user identity when git pushing via ssh?
  • Capistrano Deploy Permission Denied
  • Git post-receive hook not running following push
  • Make Github push to a remote server when it receives updates
  • Git Deploy PHP App to MULTIPLE EC2 Nodes
  • #!/bin/sh
    GIT_WORK_TREE=/home/repo/eko_web git checkout -f

    When I locally

    git push pd production

    and then go to my working tree I see all the files there but they haven’t been added or committed. If while in that tree I add and commit all those files and then restart the server on my EC2 then I can see the changes on my website. But there must be a way to have add and commit occur automatically without need a server restart, preferably reflecting the commit history on the branch I pushed from locally.

  • Issue trying to push to git repository
  • Git force push tag when the tag already exists on remote
  • Is there an easy way to manage multiple versions of git?
  • How to recover after i execute :git reset --hard HEAD
  • Manage many small (~5KB) files with git-annex
  • How to install git on Linux
  • One Solution collect form web for “Rails EC2 – Git Remote Hook Not Commiting”

    You need to locally commit the files before pushing them otherwise you won’t see them in your remote repository. From your top level working directory.

    git commit -a .

    Or if it’s new files you need to add them first.

    git add <file or directory>
    git commit

    Then you push:

    git push pd production

    Generally, you either need to restart or reload the server for your changed to take effect. If you want to do gracefully, meaning you don’t connections to get dropped it’s better to do a reload (This is usually sends a HUP signal to the process and tells it that there has been a configuration change) You could add this to your post-receive hook, something like:

    sudo service apache2 reload


    sudo service nginx reload
    Git Baby is a git and github fan, let's start git clone.