{"id":1406,"date":"2019-10-27T17:55:19","date_gmt":"2019-10-27T17:55:19","guid":{"rendered":"https:\/\/www.ciraltos.com\/?p=1406"},"modified":"2023-03-23T22:55:57","modified_gmt":"2023-03-24T03:55:57","slug":"get-started-with-git-remote","status":"publish","type":"post","link":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/","title":{"rendered":"Get Started with Git Remote"},"content":{"rendered":"\n<figure class=\"wp-block-image alignleft is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Octocat.png\" alt=\"\" class=\"wp-image-1454\" width=\"200\" height=\"166\"\/><\/figure>\n\n\n\n<p>In my last post, I eulogized the virtues of using Git for the simplest of scripts.&nbsp; You can find that <a href=\"https:\/\/www.ciraltos.com\/git-for-system-admin-scripting\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"here (opens in a new tab)\">here<\/a>.&nbsp; In this post, I go over using Git with a remote repository, namely GitHub.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>A remote repository takes all the goodness of Git on the local machine and extends it to a cloud service.&nbsp; There are several advantages to this.&nbsp; First, it provides an offsite location for scripts.&nbsp; Making scripts available anywhere that has an internet connection.&nbsp; You can access and edit scripts across multiple computers and locations. Most online repositories provide the ability to edit files directly from the interface.&nbsp; Public or private repositories provide the ability to share code or keep it private.&nbsp; Also, the code can be accessed from a URL.&nbsp; This is handy for ARM templates and CI\/CD pipelines.&nbsp; Lastly, the remote repository I\u2019m using for this article, GitHub, is free. <\/p>\n\n\n\n<p>Remote Git repositories don\u2019t synchronize changes like a OneDrive or Dropbox service.&nbsp; There is no continues sync process that happens in the background.&nbsp; Synchronization happens with either git push or git pull command.&nbsp; All of which I go over below. <\/p>\n\n\n\n<p>Remote Repositories also enable multiple editors in a repository.&nbsp; That is where branching, forking, and merging comes into play.&nbsp; This series of articles is forced on System Admins and lone scripters.&nbsp; As such, I\u2019m sticking to the basics and all editing is in the master branch for this article.<\/p>\n\n\n\n<h2>Sign Up<\/h2>\n\n\n\n<p>The first step is to sign up for an online service.&nbsp; For GitHub, go to <a href=\"http:\/\/www.github.com\">www.github.com<\/a> and set up an account and\nprofile.&nbsp; I have an account already and\ndon\u2019t plan to set another up for this article.&nbsp;\nI\u2019m sure you can figure it out.&nbsp;\nGo ahead and sign up if you don\u2019t have an existing account.&nbsp; All the steps below are similar to other cloud-based\nrepository providers such as GitLab.<\/p>\n\n\n\n<h2>Create a Public Repository<\/h2>\n\n\n\n<p>Start by creating a public repository on GitHub.&nbsp; Log in and click the button to create a new repository.&nbsp; You will see a window similar to below.&nbsp; Let\u2019s go over what these options are about.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-a-new-repository.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-a-new-repository.png\" alt=\"Create a new repository\" class=\"wp-image-1407\" width=\"544\" height=\"474\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-a-new-repository.png 725w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-a-new-repository-300x262.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/a><figcaption class=\"wp-element-caption\"> Create a new repository <\/figcaption><\/figure>\n\n\n\n<p><strong>Owner <\/strong>\u2013 That\u2019s you.&nbsp; Be sure to upload a good picture.<\/p>\n\n\n\n<p><strong>Repository name<\/strong> \u2013 The name of the new repository.  Spaces are replaced with a dash.<\/p>\n\n\n\n<p><strong>Description <\/strong>\u2013 This is optional, but add something descriptive so you can recognize what the repository is about a year from now.<\/p>\n\n\n\n<p><strong>Private or Public<\/strong> \u2013 As the description says, Public Repos are available for the world to see, private is just you and anyone you invite to it.&nbsp; Create a public repository first to follow along below.<\/p>\n\n\n\n<p><strong>Initialize with a README<\/strong> \u2013 this adds a README.md file to the repository for commenting on the repository.&nbsp; I suggest creating a README.md file to add notes or other information about the code.<\/p>\n\n\n\n<p><strong>Add .gitignore<\/strong> \u2013 This file contains file types that will not be added or synchronized from local Git to the remote repository.&nbsp; This is useful for defining items such as <em>*.log<\/em> files that don\u2019t need to be part of the repository but may find their way into the directory.&nbsp; Notice there are preconfigured options.  In the window above, I added the Terraform option.&nbsp; This prevents Terraform temp files from getting copied to the remote repository.<br><\/p>\n\n\n\n<p><strong>Add a license<\/strong> \u2013 If you want to define a license file, do it here. <\/p>\n\n\n\n<p>Once finished, click on <em>Create repository. <\/em>&nbsp;Congratulations, you now have a remote repository!\n<\/p>\n\n\n\n<h2>Pull Down Public Repository<\/h2>\n\n\n\n<p>Once the repository is created, time to copy it\nlocally.&nbsp; This is done from Git Bash on\nyour local computer.&nbsp; Open Git Bash and go\nto the directory of the parent folder for the repository.&nbsp; Git will create a new folder for the repository\nwe are about to download.<\/p>\n\n\n\n<p>Also needed is the URL for the repository.&nbsp; This can be found in the green <em>Clone or\ndownload<\/em> button in the newly created repository.&nbsp; Click the clipboard button to copy the\nURL.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Clone-or-Download.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Clone-or-Download.png\" alt=\"Clone or Download\" class=\"wp-image-1408\" width=\"362\" height=\"218\"\/><\/a><figcaption class=\"wp-element-caption\"> Clone or Download <\/figcaption><\/figure>\n\n\n\n<p>Next, run the <em>git clone<\/em> command with the URL to clone\nthe repository locally similar to below, only replace the URL with your own. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git clone <a href=\"https:\/\/github.com\/tsrob50\/BlogPost.git\">https:\/\/github.com\/tsrob50\/BlogPost.git<\/a><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Clone.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Clone.png\" alt=\"Git Clone\" class=\"wp-image-1409\"\/><\/a><figcaption class=\"wp-element-caption\"> Git Clone <\/figcaption><\/figure>\n\n\n\n<p>The repository is now available on the local computer.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Public-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"690\" height=\"377\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Public-Repo.png\" alt=\"\" class=\"wp-image-1410\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Local-Public-Repo.png 690w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Local-Public-Repo-300x164.png 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/a><figcaption class=\"wp-element-caption\"> Local Public Repository <\/figcaption><\/figure>\n\n\n\n<h2>Pull Down Private Repository<\/h2>\n\n\n\n<p>Copying down a public repository was pretty easy and can be\ndone from any publicly available repository, not just your own.&nbsp; That\u2019s not the case with private repositories.&nbsp; For private repositories, you need to\nauthenticate to GitHub in Git Bash first.&nbsp;\nStart by creating a new repository like the previous one we setup, only\ncreate it as a <em>private repository<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"437\" height=\"127\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Initialize-Private.png\" alt=\"Initialize Private\" class=\"wp-image-1411\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Initialize-Private.png 437w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Initialize-Private-300x87.png 300w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><figcaption class=\"wp-element-caption\"><br>Initialize Private <\/figcaption><\/figure>\n\n\n\n<p>Like the public repository, get the URL from the green <em>Clone\nor Download<\/em> button and run the <em>git clone<\/em> command to copy the repository\nlocally.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git clone https:\/\/github.com\/tsrob50\/BlogPostPriv.git<\/pre>\n\n\n\n<p>You should see a login prompt for GitHub as shown\nbelow.&nbsp; Sign in with your GitHub\naccount.&nbsp; The credentials will be cached going\nforward.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/GitHub-Bash-Login.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/GitHub-Bash-Login.png\" alt=\"\" class=\"wp-image-1412\" width=\"303\" height=\"305\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/GitHub-Bash-Login.png 404w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/GitHub-Bash-Login-150x150.png 150w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/GitHub-Bash-Login-298x300.png 298w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/a><figcaption class=\"wp-element-caption\"> GitHub Bash Login <\/figcaption><\/figure>\n\n\n\n<p>At this point, the private repository exists on the local\nmachine and available.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Private-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Private-Repo.png\" alt=\"\" class=\"wp-image-1414\" width=\"516\" height=\"283\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Local-Private-Repo.png 688w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Local-Private-Repo-300x164.png 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a><figcaption class=\"wp-element-caption\"> Local Private Repository <\/figcaption><\/figure>\n\n\n\n<h2>Push Changes Up<\/h2>\n\n\n\n<p>As I mentioned previously, Git does not <em>sync<\/em> files to\nthe remote repositories.&nbsp; Changes need to\nbe pushed to the remote repository. &nbsp;This\nmay seem cumbersome, but there is actually a simplicity to it.&nbsp; As users, we control when changes are committed\nand when the online copy is updated.&nbsp; <\/p>\n\n\n\n<p>In this example, I start by adding a file to the private repository\nand commit the change.&nbsp; After that, I\u2019ll\nadd content to the file and commit the change again.&nbsp; In the real world, you don\u2019t need to commit\nafter every change.&nbsp; I do it here for demonstration\npurposes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-and-Update-a-File.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"848\" height=\"462\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-and-Update-a-File.png\" alt=\"\" class=\"wp-image-1416\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-and-Update-a-File.png 848w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-and-Update-a-File-300x163.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-and-Update-a-File-768x418.png 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/a><figcaption class=\"wp-element-caption\"> Create and Update a File <\/figcaption><\/figure>\n\n\n\n<p>The file has been created and updated with two commits, but nothing has changed on the remote repository.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"414\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo-1024x414.png\" alt=\"\" class=\"wp-image-1417\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo-1024x414.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo-300x121.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo-768x310.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Unchanged-Remote-Repo.png 1027w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Changes are pushed to the remote repository with the <em>git\npush <\/em>command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git push<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Push-Command.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"843\" height=\"333\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Push-Command.png\" alt=\"\" class=\"wp-image-1418\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Command.png 843w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Command-300x119.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Command-768x303.png 768w\" sizes=\"(max-width: 843px) 100vw, 843px\" \/><\/a><figcaption class=\"wp-element-caption\">Git Push Command<\/figcaption><\/figure>\n\n\n\n<p>Go back to the repository in GitHub and you can see the file\nhas been added.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Updated-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"449\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Updated-Repo-1024x449.png\" alt=\"\" class=\"wp-image-1419\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-Repo-1024x449.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-Repo-300x132.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-Repo-768x337.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-Repo.png 1032w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\"> Updated Repository <\/figcaption><\/figure>\n\n\n\n<p>Next, go to the commit history toward the top of the\npage.&nbsp; Notice that is shows the two\ncommits done on the local machine.&nbsp; This\nis an important distinction from simply copying files to a file server.&nbsp; The change history is updated on the remote repository\nwith the push command.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Commit-History.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1014\" height=\"441\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Commit-History.png\" alt=\"\" class=\"wp-image-1420\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Commit-History.png 1014w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Commit-History-300x130.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Commit-History-768x334.png 768w\" sizes=\"(max-width: 1014px) 100vw, 1014px\" \/><\/a><figcaption class=\"wp-element-caption\"> Commit History <\/figcaption><\/figure>\n\n\n\n<h2>Update from Remote<\/h2>\n\n\n\n<p>That\u2019s all good, but what happens when you use multiple\ncomputers?&nbsp; The contents of a remote repository\nare pulled down to the local machine with the <em>git pull<\/em> command.&nbsp; In the example below, I added a new file called\nhostname.ps1 to the online repository to simulate a remote change.&nbsp; This is easy to do with the <em>Create new\nFile<\/em> command in GitHub.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-File-Online.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"363\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Create-File-Online-1024x363.png\" alt=\"\" class=\"wp-image-1421\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-File-Online-1024x363.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-File-Online-300x106.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-File-Online-768x273.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Create-File-Online.png 1051w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\"> Create File Online <\/figcaption><\/figure>\n\n\n\n<p>The local copy of the repository does not contain the new hostname.ps1\nfile.&nbsp; The local copy is updated with the\n<em>git pull<\/em> command.&nbsp; <em>Git pull<\/em>\nfetches data from another repository and integrates it with the local copy.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git pull<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Pull-Bash.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"847\" height=\"410\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Pull-Bash.png\" alt=\"\" class=\"wp-image-1422\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Pull-Bash.png 847w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Pull-Bash-300x145.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Pull-Bash-768x372.png 768w\" sizes=\"(max-width: 847px) 100vw, 847px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Pull Bash <\/figcaption><\/figure>\n\n\n\n<p>After the <em>git pull <\/em>command is run, the file created\non the remote repository now exists locally.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Private-Repo-Updated.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Local-Private-Repo-Updated.png\" alt=\"\" class=\"wp-image-1423\"\/><\/a><figcaption class=\"wp-element-caption\"> Local Private Repository Updated <\/figcaption><\/figure>\n\n\n\n<h2>Push a Locally Initialized Repository<\/h2>\n\n\n\n<p>The flow above is how I commonly create a repository.&nbsp; Start with the portal and clone it to the local computer.&nbsp; However, in my previous post I initialized a local repository called <em>First Repository<\/em>.&nbsp; What if I want to push that to a remote repository?&nbsp; Below I walk through that process.<\/p>\n\n\n\n<p>First, create a new remote repository, either public or private.&nbsp; This is where the local repository will be\npushed to.&nbsp; &nbsp;Do not create a readme or .gitignore\nfile.&nbsp; For this example, the remote repository\nis empty.&nbsp; Copy the repository URL to the\nclipboard for the next step.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Push-Locally-Initialized-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1019\" height=\"617\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Push-Locally-Initialized-Repo.png\" alt=\"\" class=\"wp-image-1424\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Push-Locally-Initialized-Repo.png 1019w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Push-Locally-Initialized-Repo-300x182.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Push-Locally-Initialized-Repo-768x465.png 768w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><figcaption class=\"wp-element-caption\"> Push Locally Initialized Repository <\/figcaption><\/figure>\n\n\n\n<p>Go to Git Bash and navigate to the folder with the local repository,\nin my case it\u2019s the <em>First Repo<\/em> folder.&nbsp;\nFrom there, the remote repository is added with the command below.&nbsp; Replace the URL with the URL for your repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git remote add First-Repository\nhttps:\/\/github.com\/tsrob50\/First-Repo.git <\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Remote-Add-Remote.png\"><img decoding=\"async\" loading=\"lazy\" width=\"848\" height=\"411\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Remote-Add-Remote.png\" alt=\"\" class=\"wp-image-1425\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Remote-Add-Remote.png 848w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Remote-Add-Remote-300x145.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Remote-Add-Remote-768x372.png 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Remote Add Remote <\/figcaption><\/figure>\n\n\n\n<p>This adds the remote location to the local repository.&nbsp; Next, the remote repository is set as the master with the command below.&nbsp; Replacing <em>First-Repo<\/em> with the name of your repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git push --set-upstream First-Repo master<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Push-Set-Upstream-Master.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"849\" height=\"410\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Git-Push-Set-Upstream-Master.png\" alt=\"\" class=\"wp-image-1426\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Set-Upstream-Master.png 849w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Set-Upstream-Master-300x145.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Git-Push-Set-Upstream-Master-768x371.png 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption class=\"wp-element-caption\"> Git Push Set Upstream Master <\/figcaption><\/figure>\n\n\n\n<p>Files in the local repository are now available at the remote location.&nbsp; The remote repository is also set to master and will  behave similarly to the repose set up previously in this article. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Updated-First-Repo.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1009\" height=\"508\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2019\/10\/Updated-First-Repo.png\" alt=\"\" class=\"wp-image-1427\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-First-Repo.png 1009w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-First-Repo-300x151.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2019\/10\/Updated-First-Repo-768x387.png 768w\" sizes=\"(max-width: 1009px) 100vw, 1009px\" \/><\/a><figcaption class=\"wp-element-caption\"> Updated First Repository <\/figcaption><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p>This post went over using the three commands; <em>git clone, get push <\/em>and<em> git pull<\/em> to keep a remote repository up to date with changes. &nbsp;It also went over using the <em>git remote and get push <\/em>commands to copy a locally initialized repository to a remote repository and set the remote to master.<\/p>\n\n\n\n<p>If you have read this far, congratulations.&nbsp; You have the fundamentals down and well on your way to using Git for all your scripting needs.&nbsp; You may be thinking <em>that\u2019s kind of complicated, is it worth it?<\/em>&nbsp; The answer is yes, yes it is.&nbsp; My next article is going to simplify this process with Git integration into an IDE, specifically Microsoft VS Code.<\/p>\n\n\n\n<p>Read Next:  <a href=\"https:\/\/www.ciraltos.com\/git-and-vs-code-for-the-lone-scripter\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Git and VS Code for the Lone Scripter (opens in a new tab)\">Git and VS Code for the Lone Scripter<\/a><br><a href=\"https:\/\/www.ciraltos.com\/git-and-vs-code-for-the-lone-scripter\/\">h<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post, I eulogized the virtues of using Git for the simplest of scripts.&nbsp; You can find that here.&nbsp; In this post, I go over using Git with a remote repository, namely GitHub.<\/p>\n","protected":false},"author":1,"featured_media":3989,"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":[582,583,230,210,579,341,338,20,340,68],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get Started with Git Remote - ciraltos<\/title>\n<meta name=\"description\" content=\"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.\" \/>\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\/get-started-with-git-remote\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Started with Git Remote - ciraltos\" \/>\n<meta property=\"og:description\" content=\"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\" \/>\n<meta property=\"og:site_name\" content=\"ciraltos\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-27T17:55:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T03:55:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Octocat.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"665\" \/>\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\/get-started-with-git-remote\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\"},\"author\":{\"name\":\"Travis Roberts\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"headline\":\"Get Started with Git Remote\",\"datePublished\":\"2019-10-27T17:55:19+00:00\",\"dateModified\":\"2023-03-24T03:55:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\"},\"wordCount\":1619,\"commentCount\":1,\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"keywords\":[\".bat file\",\".ps1 file\",\"Automation\",\"Azure Automation\",\"Bash\",\"git\",\"github\",\"Powershell\",\"runbooks\",\"script\"],\"articleSection\":[\"PowerShell\",\"Trends\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\",\"name\":\"Get Started with Git Remote - ciraltos\",\"isPartOf\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\"},\"datePublished\":\"2019-10-27T17:55:19+00:00\",\"dateModified\":\"2023-03-24T03:55:57+00:00\",\"description\":\"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.ciraltos.com\/staging2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Started with Git Remote\"}]},{\"@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":"Get Started with Git Remote - ciraltos","description":"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.","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\/get-started-with-git-remote\/","og_locale":"en_US","og_type":"article","og_title":"Get Started with Git Remote - ciraltos","og_description":"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.","og_url":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/","og_site_name":"ciraltos","article_published_time":"2019-10-27T17:55:19+00:00","article_modified_time":"2023-03-24T03:55:57+00:00","og_image":[{"url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Octocat.png","width":800,"height":665,"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\/get-started-with-git-remote\/#article","isPartOf":{"@id":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/"},"author":{"name":"Travis Roberts","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"headline":"Get Started with Git Remote","datePublished":"2019-10-27T17:55:19+00:00","dateModified":"2023-03-24T03:55:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/"},"wordCount":1619,"commentCount":1,"publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"keywords":[".bat file",".ps1 file","Automation","Azure Automation","Bash","git","github","Powershell","runbooks","script"],"articleSection":["PowerShell","Trends"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/","url":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/","name":"Get Started with Git Remote - ciraltos","isPartOf":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#website"},"datePublished":"2019-10-27T17:55:19+00:00","dateModified":"2023-03-24T03:55:57+00:00","description":"This post goes over using the three commands; git clone, get push and git pull to keep a remote repository up to date with changes. It also goes over using the git remote and get push commands to copy a locally initialized repository to a remote repository and set the remote to master.","breadcrumb":{"@id":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ciraltos.com\/staging2\/get-started-with-git-remote\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.ciraltos.com\/staging2\/"},{"@type":"ListItem","position":2,"name":"Get Started with Git Remote"}]},{"@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\/1406"}],"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=1406"}],"version-history":[{"count":12,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"predecessor-version":[{"id":4003,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1406\/revisions\/4003"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media\/3989"}],"wp:attachment":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media?parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/categories?post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/tags?post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}