Lessons in Linux

TALK TECH TO ME : MANAGING LINUX SHELL SCRIPTS USING GIT May 13, 2019 by Jason W. Eckert

Most Linux administrators today create a plethora of different shell scripts to automate system administration tasks on their servers. However, it can be challenging to coordinate and keep track of all of the different shell scripts on a large number of different systems or locate and copy the right shell scripts to a newly provisioned server. You can use Git to centrally store a master copy of your shell scripts and organize the changes that you and your fellow administrators make across multiple servers. What Is Git? Git is a version control system that can be used to keep track of the changes you make to files over time – it allows you to revert files to a previous state or see who made changes to a file at different times if several people are working the those files collaboratively. Git was originally developed in 2005 by Linus Torvalds (the creator of Linux) to aid in making changes to the Linux kernel, but has since become the most common open-source version control system used today. You can run Git on most platforms, including Windows, Linux and macOS. Although people primarily use it for version controlling software projects, you can use it to provide version control for any files on your system. In this post, we’ll use it to provide version control and central access for Linux shell scripts. How to Use Git for Local Version Control Git essentially takes snapshots (called commits ) of the files that you have within a particular folder (called a repository , or repo ) on your system.

Each commit contains the changes you’ve made to the files since the last commit, so you can easily rollback those changes (much like a Windows System Restore point).

git config Before you use Git to create commits, you must first tell Git about yourself using the git config command, since that information must be added to each commit that you create: [jason.eckert@csc-studev01 myscripts]$ git config --global user.name “Jason Eckert” [jason.eckert@csc-studev01 myscripts]$ git config --global user.email “jasonec@trios.com” To turn an existing folder into a Git repo, simply use the git init command.

Made with FlippingBook Online document