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.

  • Git Server Setup using Apache 2.2 on Windows 7
  • git sparse checkout and shallow clone issue with github
  • Python Git Bash CMD Script
  • Can git automatically split up a commit into single hunks?
  • How to preserve line endings when extracting git commit messages in a bash script?
  • Get a list of changed files between two commits or branches
  • Can anyone point me in the right direction?

  • Java projects within branch treated as separated branch or tags in git from svn?
  • Git selectively ignoring despite gitignore file
  • git add -A :/ on Git 2.X and relationship with pathspec
  • gitting from branch to production
  • Why am I getting the message, “fatal: This operation must be run in a work tree?”
  • Why would I ever git checkout --detach
  • 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.