Automate Git Repository Setup with Python & Fabric

I love Git.  I find Git to be an intuitive way to track many versions between many systems.  Now all my default config files and scripts utilize Git.  However, logging into a server and creating the Git repo, then cloning it is a number of steps that detracts from getting work done.  

This tutorial outlines a basic example of using Fabric(Python automation module) to automate the process of creating  a ‘mycode.git’ repository and cloning it.  This tutorial was written for Cent OS 6.5, but could be adapted for Ubuntu and Fedora.  Basic knowledge of Linux and Python 3 is required.

If you need help setting up Python3, pip, and Fabric on CentOS 6 please refer to my earlier tutorial: https://www.savelono.com/linux/how-to-install-python-3-and-pip-3-for-centos-6.html

Goals of this post:

  • Write Python/Fabric function to automate the Git setup process
  • Write Python/Fabric function to automate cloning Git repository on local host