{"id":1368,"date":"2019-10-12T02:07:15","date_gmt":"2019-10-12T02:07:15","guid":{"rendered":"https:\/\/www.ciraltos.com\/?p=1368"},"modified":"2023-03-23T22:56:19","modified_gmt":"2023-03-24T03:56:19","slug":"git-for-system-admin-scripting","status":"publish","type":"post","link":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/","title":{"rendered":"Git for System Admin Scripting"},"content":{"rendered":"\n<figure class=\"wp-block-image alignleft\"><img decoding=\"async\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/git.png\" alt=\"Git\" class=\"wp-image-1369\"\/><\/figure>\n\n\n\n<p>I spent most of my time in IT as a system admin, on the \u201cOps\u201d side of DevOps.&nbsp; Over the years, I have accumulated many different batch files and scripts of one type or another.&nbsp; File shares worked well for storing the code I write.&nbsp; I discovered Git and it\u2019s become my main repository for all script related code.&nbsp; Recently, I attempted to make a case to other admins for using Git, but failed to make a convincing case.&nbsp; Below, I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git.&nbsp; I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.&nbsp; <\/p>\n\n\n\n<!--more-->\n\n\n\n<h2>What is Git?<\/h2>\n\n\n\n<p>Git is a free, efficient, and local version control system. It\nallows for distributed collaboration.&nbsp;\nFiles are edited locally and changes sent to a central repository.&nbsp; If you spend some time researching the topic\nonline, it\u2019s easy to get bogged down in branching and forking and remote\npushes.&nbsp; Don\u2019t get caught up in\nthat.&nbsp; Odds are you don\u2019t have multiple\ndevelopers working on scripts (but if you do, Git will support that also).&nbsp; Let\u2019s focus on free, local and version\ncontrol for now.<\/p>\n\n\n\n<h2>Why bother?<\/h2>\n\n\n\n<p>At the heart of Git is a version control system with\ncommented commits.&nbsp; File systems have\nbackups (sometimes), but that doesn\u2019t track significant changes made during\nediting and testing scripts.&nbsp; Reverting\nback to a version changed multiple times during a day may not be possible\nunless you made copies of the file along the way.&nbsp; That\u2019s inefficient and keeping track of the\nversion will become impossible after a while.&nbsp;\n<\/p>\n\n\n\n<p>When code is stored in an online or internal repository such\nas GitHub and GitLab, it can be called from the online source and ran without\nbeing stored locally.&nbsp; This is useful for\ncloud-config files such as JSON templates or Terraform files.&nbsp; This also makes a case for Git and its role\nin DevOps.<\/p>\n\n\n\n<p>I have also found that some organizations lock down USB\ndrives or cloud storage such as OneDrive and Dropbox, making portability\ndifficult.&nbsp; Most allow access to\nGitHub.&nbsp; <\/p>\n\n\n\n<p>The last reason to move to Git is that it\u2019s cool.&nbsp; Not a good enough reason?&nbsp; Over the past 20 years I have seen (or been\npart of) sysadmins buying a lot of crazy stuff because it\u2019s cool.&nbsp; So, don\u2019t discount the cool factor.&nbsp; <\/p>\n\n\n\n<h2>How does it work?<\/h2>\n\n\n\n<p>Some of you may have experience with a code repository like\nTeam Foundation Server.&nbsp; The code is kept\non the server, checked out, modified and checked in.&nbsp; That\u2019s not how Git works.&nbsp; Git is local, no server is needed.&nbsp; You only need the Git application installed\non a local machine to use it. <\/p>\n\n\n\n<p>Git stores data in a hidden folder in the same directory as\nthe files, this becomes the root of the repository (repo).&nbsp; One simple command, <em>git init<\/em> (for\ninitialize) sets up the Git repo (I walk through this process below).&nbsp; This command enables all files and subfiles\nto be part of the repo.&nbsp; <\/p>\n\n\n\n<p>Once <em>git init<\/em> is ran, it\u2019s time to create some content.  Edit and save scripts to the folder.&nbsp; At some point you are going to have a version you want to keep for prosperity.&nbsp; Maybe an official version or just a version that working and you want to create a checkpoint before moving on.&nbsp; Now it\u2019s time to put Git to work.&nbsp; To create that checkpoint, I need two commands, <em>git add<\/em> and <em>git commit<\/em>.<\/p>\n\n\n\n<p>The first command, <em>git add<\/em>, adds the file to the\nindex, but does not update anything.&nbsp; It\nonly adds the files to be committed in the next step. <\/p>\n\n\n\n<p>Now the file has been added, Git knows about it, but it hasn\u2019t been \u201ccheeked in\u201d. to do that, I run the <em>git commit<\/em> command.&nbsp; This command commits the file to Git, creating a checkpoint.&nbsp; The <em>git commit<\/em> command has a required comment or message \u201c-m\u201d used to track the commit.&nbsp; It may be tempting to put something simple like \u201cupdate\u201d, \u201ccheck-in\u201d, or \u201cblah, blah, blah\u201d, but don\u2019t.&nbsp; The reason you have read this far is that you see value in tracking changes to your scripts.&nbsp; Add something meaningful for future reference.&nbsp; <\/p>\n\n\n\n<p>That\u2019s it; <em>git init,<\/em> <em>git add<\/em> and <em>git commit<\/em>\nwill take you 95% of the way with Git.&nbsp;\nThere is more, a lot more.&nbsp; I\nintend to cover integrating Git into editors such as VSCode and online\nrepositories in upcoming posts.&nbsp; But first,\nlets setup Git and create a repo.<\/p>\n\n\n\n<h2>Set up Git<\/h2>\n\n\n\n<p>The first step is to download and install Git.&nbsp; There are two options, a GUI client and a Bash\nversion.&nbsp; I recommend and will be using\nthe Bash version.&nbsp; The GUI client has a\nlot of features that I haven\u2019t used.&nbsp; The\nBash version is more universal, working the same no matter the platform it\u2019s\nrunning on.&nbsp; Download the version for\nyour OS from here <a href=\"https:\/\/git-scm.com\/downloads\">https:\/\/git-scm.com\/downloads<\/a>\nand run the installer.<\/p>\n\n\n\n<p>All options can be left as default.&nbsp; The only one you may want to change is the <em>default\neditor used by Git<\/em>.&nbsp; It\u2019s set to Vim\nby default, changed it to something different if you would like.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Default-Editor.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"499\" height=\"388\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Default-Editor.png\" alt=\"\" class=\"wp-image-1370\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Default-Editor.png 499w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Default-Editor-300x233.png 300w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Default Editor <\/figcaption><\/figure>\n\n\n\n<p>You should see some Git options on the start menu.&nbsp; Run <em>Git Bash<\/em> to get started. From the\nprompt, run git version to verify it\u2019s working.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Version.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"828\" height=\"502\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Version.png\" alt=\"\" class=\"wp-image-1371\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Version.png 828w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Version-300x182.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Version-768x466.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Version <\/figcaption><\/figure>\n\n\n\n<p>Congratulations, you now have Git installed.&nbsp; Before I move on, let&#8217;s give Git our user\ninformation.&nbsp; Do this with the two\ncommands below to assign your user name and email address.&nbsp; These will be used to track who is making\nchanges, not that critical in an environment of one, but important as I move\nalong.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Git config --global user.name \u201cuser name\u201d\nGit config --global user.email <a href=\"mailto:user@email.com\">\"user@email.com<\/a>\" <\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/User-Name-and-Email.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"827\" height=\"257\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/User-Name-and-Email.png\" alt=\"\" class=\"wp-image-1372\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/User-Name-and-Email.png 827w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/User-Name-and-Email-300x93.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/User-Name-and-Email-768x239.png 768w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/a><figcaption class=\"wp-element-caption\">  User Name and Email  <\/figcaption><\/figure>\n\n\n\n<h2>First Repo<\/h2>\n\n\n\n<p>Now for the fun part.&nbsp;\nCreate a folder on your computer, I\u2019ll create a folder called <em>First\nRepo<\/em> under my documents for this demonstration.&nbsp; Create a text file in the directory.&nbsp; The name is not important, I called mine <em>test.txt<\/em>.&nbsp; I also added a single line of text to give it\na little content.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/First-Git-File.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"783\" height=\"378\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/First-Git-File.png\" alt=\"\" class=\"wp-image-1374\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/First-Git-File.png 783w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/First-Git-File-300x145.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/First-Git-File-768x371.png 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/a><figcaption class=\"wp-element-caption\"> First Git File <\/figcaption><\/figure>\n\n\n\n<p>Save the file and go back to Git Bash.&nbsp; Now that I have a little content, let\u2019s\ninitialize the repo.&nbsp; This is done with\nthe <em>git init<\/em> command.&nbsp; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git init \u201cC:\\Users\\Administrator\\Documents\\First Repo\u201d<\/pre>\n\n\n\n<p>Alternatively, you could run the <em>git init<\/em> command\nfrom the directory without the path.<\/p>\n\n\n\n<p>You have now created a Git repo.&nbsp; Go back into the folder and if Windows Explorer\nis set to default, you won\u2019t notice anything different.&nbsp; However, if you enable view <em>hidden items<\/em>,\nyou should see a new hidden folder named .git.&nbsp;\nThis is where Git does its work.&nbsp;\nThere is a lot going on in this folder, but I\u2019m focusing on how to use\nGit, not how it works.&nbsp; For now, it\u2019s\nsufficient to know this is where all the indexing information is stored for\nthis repo.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Hidden-Folder.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"752\" height=\"312\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Hidden-Folder.png\" alt=\"\" class=\"wp-image-1375\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Hidden-Folder.png 752w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Hidden-Folder-300x124.png 300w\" sizes=\"(max-width: 752px) 100vw, 752px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Hidden Folder <\/figcaption><\/figure>\n\n\n\n<h3>Git Add <\/h3>\n\n\n\n<p>Now the repo is set up, next I add or stage a file to\nit.&nbsp; I moved into my repo directory so I don\u2019t\nneed to append the path to commands.&nbsp; I\nran the <em>git ls-files<\/em> command and it returns nothing because, well, I haven\u2019t\nadded anything.&nbsp; The <em>git status <\/em>command\nconfirms that my file, <em>test.txt<\/em> is not tracked.&nbsp; It even tells me how to add it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/No-File-Added.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"826\" height=\"488\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/No-File-Added.png\" alt=\"\" class=\"wp-image-1376\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/No-File-Added.png 826w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/No-File-Added-300x177.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/No-File-Added-768x454.png 768w\" sizes=\"(max-width: 826px) 100vw, 826px\" \/><\/a><figcaption class=\"wp-element-caption\"> No File Added <\/figcaption><\/figure>\n\n\n\n<p>Next, the file is added to Git.&nbsp; Run the <em>git add<\/em> command to add the\nfile.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git add test.txt<\/pre>\n\n\n\n<p>Once ran, the <em>git status <\/em>command shows a file added\nbut not committed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Add-Command.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"828\" height=\"336\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Add-Command.png\" alt=\"\" class=\"wp-image-1377\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Add-Command.png 828w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Add-Command-300x122.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Add-Command-768x312.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Add Command <\/figcaption><\/figure>\n\n\n\n<h3>Git Commit<\/h3>\n\n\n\n<p>The file is committed with the <em>git commit<\/em>\ncommand.&nbsp; This creates a checkpoint in\nthe Git index used for tracking changes.&nbsp;\nThe command requires a message for the commit.&nbsp; This is the comment used to identify what\nchanged, or the significance of the commit.&nbsp;\nThe best practice is to put something meaningful in the message.&nbsp; After all, there is no point in tracking\nchanges if the only notes on the change are \u201cupdated files\u201d or \u201cchecked in\u201d.&nbsp; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git commit -m \u201cinitial commit\u201d<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Commit-Command.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"825\" height=\"214\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Commit-Command.png\" alt=\"\" class=\"wp-image-1378\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Commit-Command.png 825w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Commit-Command-300x78.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Commit-Command-768x199.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git status Command<br><\/figcaption><\/figure>\n\n\n\n<p>The file has now been committed.&nbsp; Running the git status command shows updated\ninformation.&nbsp; Also, the <em>git ls-files<\/em>\nnow show the file added to the repo.&nbsp; <\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p>Did a text editor open when running a commit?&nbsp; That means you left off the <em>-m \u201ccomment\u201d<\/em>.&nbsp; It\u2019s telling you it needs a comment and kindly opened a text editor so you can do so.&nbsp; Enter a comment and save to continue.&nbsp; If you find yourself stuck in Vim, hit the Esc key, then colon : and type q!, press enter.&nbsp; <\/p>\n<\/blockquote>\n\n\n\n<h2>Change tracking<\/h2>\n\n\n\n<p>To illustrate the change tracking ability of Git, I first\nneed to change the file.&nbsp; I added some\ntest to my test file and saved it.&nbsp; Next,\nI run the git add and git command again as I did before.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Second-Commit.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"828\" height=\"264\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Second-Commit.png\" alt=\"\" class=\"wp-image-1380\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Second-Commit.png 828w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Second-Commit-300x96.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Second-Commit-768x245.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/a><figcaption class=\"wp-element-caption\"> Second Commit <\/figcaption><\/figure>\n\n\n\n<p>The commit history is displayed with the <em>git log<\/em>\ncommand as shown below. &nbsp;Now you can see\nhow all the work so far has paid off.&nbsp; The\noutput shows who made the changes, at what time and gives the comment\ninformation.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Log-Command-1.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Log-Command-1.png\" alt=\"\" class=\"wp-image-1386\"\/><\/a><figcaption class=\"wp-element-caption\"> Git Log Command <\/figcaption><\/figure>\n\n\n\n<p>This is all good, but what if you want to look at one of\nthose previous versions?&nbsp; That is easy to\ndo with the <em>git show<\/em> command.&nbsp; The\n<em>git show<\/em> command requires the hash value (shown after <em>commit<\/em> in\nthe image above) and the path to the file.&nbsp;\nBelow shows the output from both of my commits along with the content of\nthe file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git show &lt;Commit Hash&gt;:file\/path<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Show-Command.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"848\" height=\"215\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Show-Command.png\" alt=\"\" class=\"wp-image-1382\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Show-Command.png 848w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Show-Command-300x76.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Show-Command-768x195.png 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Show Command <\/figcaption><\/figure>\n\n\n\n<h2>Is it worth it?<\/h2>\n\n\n\n<p>When I first started using Git it seemed like a lot of extra\nsteps.&nbsp; It may seem redundant to have to\ndo a <em>git add <\/em>and a <em>git commit<\/em> to commit the file, but it makes\nsense if the directory has a lot of files.&nbsp;\nThe <em>git add<\/em> command provides the ability to selectively add files.\n<\/p>\n\n\n\n<p>Keep in mind, the whole process is much easier with a code editor\nthat has Git integration.&nbsp; Also, pushing\nchanges to a central repository keeps a copy in a secure offsite location.&nbsp; That\u2019s safer than a USB thumb drive!<\/p>\n\n\n\n<p>To return to my original motive, Git provides:<\/p>\n\n\n\n<ul>\n<li>Efficient commented version control<\/li>\n\n\n\n<li> Local and Free<\/li>\n\n\n\n<li> Sync to secure off-site hosted repositories (and GitHub is free)<\/li>\n\n\n\n<li> It\u2019s cool<\/li>\n<\/ul>\n\n\n\n<p>That makes it worth it for me!<\/p>\n\n\n\n<p>Now that I\u2019ve covered the basics, coming soon is using Git with a VSCode and a remote repository.<\/p>\n\n\n\n<p>Link <a href=\"https:\/\/www.ciraltos.com\/get-started-with-git-remote\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Get Started with Git Remote (opens in a new tab)\">Get Started with Git Remote<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent most of my time in IT as a system admin, on the \u201cOps\u201d side of DevOps.&nbsp; Over the years, I have accumulated many different batch files and scripts of one type or another.&nbsp; File shares worked well for storing the code I write.&nbsp; I discovered Git and it\u2019s become my main repository for &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\"> <span class=\"screen-reader-text\">Git for System Admin Scripting<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":3972,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[170,8],"tags":[210,579,341,338,20,340,68,198],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git for System Admin Scripting - ciraltos<\/title>\n<meta name=\"description\" content=\"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git for System Admin Scripting - ciraltos\" \/>\n<meta property=\"og:description\" content=\"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\" \/>\n<meta property=\"og:site_name\" content=\"ciraltos\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-12T02:07:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T03:56:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/git.png\" \/>\n\t<meta property=\"og:image:width\" content=\"220\" \/>\n\t<meta property=\"og:image:height\" content=\"92\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Travis Roberts\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:site\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Travis Roberts\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\"},\"author\":{\"name\":\"Travis Roberts\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"headline\":\"Git for System Admin Scripting\",\"datePublished\":\"2019-10-12T02:07:15+00:00\",\"dateModified\":\"2023-03-24T03:56:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\"},\"wordCount\":1874,\"commentCount\":5,\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"keywords\":[\"Azure Automation\",\"Bash\",\"git\",\"github\",\"Powershell\",\"runbooks\",\"script\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Trends\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\",\"name\":\"Git for System Admin Scripting - ciraltos\",\"isPartOf\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\"},\"datePublished\":\"2019-10-12T02:07:15+00:00\",\"dateModified\":\"2023-03-24T03:56:19+00:00\",\"description\":\"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.ciraltos.com\/staging2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git for System Admin Scripting\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\",\"url\":\"http:\/\/www.ciraltos.com\/staging2\/\",\"name\":\"ciraltos\",\"description\":\"cloud, technology and trends\",\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\",\"name\":\"Travis Roberts\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"contentUrl\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"width\":5657,\"height\":3563,\"caption\":\"Travis Roberts\"},\"logo\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.ciraltos.com\",\"https:\/\/twitter.com\/ciraltos\"],\"url\":\"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git for System Admin Scripting - ciraltos","description":"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/","og_locale":"en_US","og_type":"article","og_title":"Git for System Admin Scripting - ciraltos","og_description":"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.","og_url":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/","og_site_name":"ciraltos","article_published_time":"2019-10-12T02:07:15+00:00","article_modified_time":"2023-03-24T03:56:19+00:00","og_image":[{"width":220,"height":92,"url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/git.png","type":"image\/png"}],"author":"Travis Roberts","twitter_card":"summary_large_image","twitter_creator":"@ciraltos","twitter_site":"@ciraltos","twitter_misc":{"Written by":"Travis Roberts","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#article","isPartOf":{"@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/"},"author":{"name":"Travis Roberts","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"headline":"Git for System Admin Scripting","datePublished":"2019-10-12T02:07:15+00:00","dateModified":"2023-03-24T03:56:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/"},"wordCount":1874,"commentCount":5,"publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"keywords":["Azure Automation","Bash","git","github","Powershell","runbooks","script","Scripting"],"articleSection":["PowerShell","Trends"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/","url":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/","name":"Git for System Admin Scripting - ciraltos","isPartOf":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#website"},"datePublished":"2019-10-12T02:07:15+00:00","dateModified":"2023-03-24T03:56:19+00:00","description":"I lay out my case to why a sysadmin or anyone writing any kind of script should move to Git. I also outline how I use it in an effort to make my case and help anyone interested in getting started with Git.","breadcrumb":{"@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ciraltos.com\/staging2\/git-for-system-admin-scripting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.ciraltos.com\/staging2\/"},{"@type":"ListItem","position":2,"name":"Git for System Admin Scripting"}]},{"@type":"WebSite","@id":"http:\/\/www.ciraltos.com\/staging2\/#website","url":"http:\/\/www.ciraltos.com\/staging2\/","name":"ciraltos","description":"cloud, technology and trends","publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a","name":"Travis Roberts","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/","url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","contentUrl":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","width":5657,"height":3563,"caption":"Travis Roberts"},"logo":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.ciraltos.com","https:\/\/twitter.com\/ciraltos"],"url":"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1368"}],"collection":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/comments?post=1368"}],"version-history":[{"count":11,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1368\/revisions"}],"predecessor-version":[{"id":4001,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1368\/revisions\/4001"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media\/3972"}],"wp:attachment":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media?parent=1368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/categories?post=1368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/tags?post=1368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}