Bash Script to Push/Pull from Private Git Repository?

I’m trying to find a way that I can write a bash script that will auto-pull from our Private Github Repository every midnight and update our development site.

Our repo is private for obvious reasons and anything close that I’ve found always asks for the passphrase. Our server has it’s own Github Account that it uses to push and pull from the repository but I just don’t know how to do that automatically.

Can anyone point me in the right direction?

  • GitHub merge failed and deleted half my project
  • How can one efficiently maintain a cache of Git repository queries?
  • How to make git work to push commits to GitHub via tor?
  • Automatically publish git projects to github
  • Git: fatal: unable to find remote helper for 'ssl'
  • Git fetch/pull have stopped working
  • Error when using install_github: 'exdir' does not exist
  • Clone subfolder using Github Desktop
  • One Solution collect form web for “Bash Script to Push/Pull from Private Git Repository?”

    In order to automate your push/pull, you’ll need to set up passwordless authentication. To do so, you use ssh (instead of https). If you haven’t used ssh with github, or at all, before, then you’ll need to perform a few steps to get things configured.

    On your machine, generate an ssh key:

    $ ssh-keygen -t rsa
    

    Make sure you leave the passphrase field blank. This leaves the local private key unencrypted, but no less secure for the actual communication over the internet.

    Then, upload ~/.ssh/id_rsa.pub to github under Account Settings | SSH Keys

    Now you should be able to push and pull from that machine without a password. Try it out:

    git clone git@github.com:user/repo.git
    

    You can then put these commands in your bash script as appropriate. If you need to do this for multiple machines, you’ll need to upload each key, or copy the private key (~/.ssh/id_rsa) to each one.

    See github help for more info. Also take a look at the deploy keys page, as that may provide better granularity of security for your situation.

    Git Baby is a git and github fan, let's start git clone.