AWS git clone or pull not working and no error message

07
2014-07
  • zzlalani

    In one of AWS/AMI instance, I'm trying to git clone ... it says Cloning into '<repo name>'... but it doesn't clone the repository and not showing any error or any other messages, I have also tried with different repositories that are already working at other servers,

    I have also tried to upload complete code with .git dir, it shows the correct state with git status and shows branch with git branch but the command git pull is not working either nor showing any error message.

    UPDATE 1: I just tried doing git fetch --all, and got the following error:

    Fetching origin
    error: Could not fetch origin
    

    UPDATE 2: When I changed remote origin to use ssh instead of https path, and did git fetch --all or git clone, I got the following error:

    Fetching origin
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    error: Could not fetch origin
    

    Please note that I am committing to the same repository from my local machine.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    Scheduled Push Changes To Local Git Repository (Ubuntu)
  • kieran_delaney

    Boring Background - Summary: I know we're not using GIT properly!.
    This started as a small hobby project and has spiralled - my company uses Git to track/manage changes to a bespoke web-based software platform and act as a central repository. Approximately 300 mobile devices are then set to pull to a local cloned repository on start up from a self-hosted intranet server so that they may access the latest version of the software when not connected to the network (we make use of branches so that they are only exposed to mature/tested code).

    We've now moved on a step - we have a database of "parts" that is updated daily. I have created a separate version of this database using cron scripts to create a standalone version that could be opened on a local "unconnected machine".

    My Problem
    I have a set of PHP scripts that take database table data and export it into the flat file format required by the application, and copy any additional images since last cycle into the correct locations. All files are stored in /var/www/clonedrepository

    I then want to run the following commands on the directory:

    git add .
    git commit -m "Automatic update: todaysdate"
    git push
    

    The repository is cloned from /home/git/repository which is served using the git deamon and apache symlink allowing http access (for dumb device cloning) and SSH (for grownups to edit/update).

    The problem is, I'm a web programmer and I'm out of my depth. I set up the git repositories and am comfortable with the command line, but I don't know the best place to start.

    Side note: There will never be conflicts as no user will edit the data files and the system will not edit anything other than the data files.

    So in summary, I've got a central repository on my Ubuntu Linux box (/home/git/repository) that I would like to update daily from a cloned repository (/var/www/clonedrepository) on the same box.


  • Related Answers
  • kieran_delaney

    OK, so I worked this out myself...

    1) I have set up a script that contains the following lines:

    cd /var/www/partsdb/ >> /home/git/push.log
    git pull >> /home/git/push.log
    git add . >>/home/git/push.log
    git commit -a -m "Scheduled Commit: `date`" >>/home/git/push.log
    git push >> /home/git/push.log
    echo "Push Backup Successful `date`" >> /home/git/push.log
    

    This script moves to the working repository, pulls any changes from the central repository (remember these changes will only affect program files, not data files), adds any altered data files (stored in a /data sub-directory for clarity) commits the changes (including an automatic date based message to track changes/blame) and then pushes back to the repository.

    EDIT: I have since added the -a flag to the commit command, which will then remove any files deleted by the automated update scripts (add . added any new files).[/EDIT]

    2) I call this script from crontab, executing the script as root (as root is only user who has permission to write in both git's home folder and the /var/www folder) using the command:

    0 * * * * root /home/git/gitpush.sh
    

    This runs the script on an hourly basis - while isolated mobile devices will only pull from the database on startup (daily/am) local network users will always have the most up to date version (that has been pushed to master branch).