{"id":19904,"date":"2020-07-22T00:45:41","date_gmt":"2020-07-22T07:45:41","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19904"},"modified":"2023-12-01T03:55:31","modified_gmt":"2023-12-01T11:55:31","slug":"git-add-remote","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/git-add-remote\/","title":{"rendered":"Git Add Remote: A Beginner\u2019s Guide"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Add a Remote to a Git Repository <\/h2>\n\n\n\n<p>Have you just started a new <a href=\"https:\/\/careerkarma.com\/blog\/what-is-git\/\">Git repository<\/a> on your local machine? You\u2019ll need to add a remote if you intend on linking it to a remote repository.<br><\/p>\n\n\n\n<p>The git remote add command adds a remote to a Git repository. In this guide, we\u2019re going to talk about what remotes are, how they work, and how you can add a remote to a repository. Without further ado, let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Git Remote?<\/h2>\n\n\n\n<p>A Git remote is a connection to another repository.<br><\/p>\n\n\n\n<p>When you set a remote, you can push code to and pull code from a remote repository. A remote repository could be hosted on GitHub, BitBucket, GitLab, or another version control platform.<br><\/p>\n\n\n\n<p>Remotes are an essential part of the Git system. Git is distributed, which means that many different developers can have their own copy of a project. They can work on a project on their local computers without changing the main version of the project.<br><\/p>\n\n\n\n<p>Once a developer has finished making changes to a repository, they can push it to the remote version. This will make their code accessible to all the collaborators on a project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The git remote add Command<\/h2>\n\n\n\n<p>You can use git remote add to add a remote to a Git repository. This Git command is commonly run after you have cloned a repository or when you are creating a new repository.<br><\/p>\n\n\n\n<p>Let\u2019s initialize a new local repository on our machine. We\u2019ll create a new Git repository, make a README.md file, and commit that file to the repository.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git init\ncat &quot;# demo-repository&quot; &gt; README.md\ngit commit -m &quot;docs: Create README.md&quot;<\/pre><\/div>\n\n\n\n<p>Our repository has one commit. Before we can push this repository to another source, we will need to add a new remote repo:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git remote add origin https:\/\/github.com\/Career-Karma-Tutorials\/demo-repository<\/pre><\/div>\n\n\n\n<p>This creates a reference to a repository hosted on GitHub called demo-repository. The name of our reference is \u201corigin\u201d. \u201corigin\u201d is the standard label used to refer to the main version of a project. You can set the name of your reference to be whatever you want.<br><\/p>\n\n\n\n<p>We can check that our remote has been set using the <code>git remote -v<\/code> command:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git remote -v \n\n&gt; origin https:\/\/github.com\/Career-Karma-Tutorials\/demo-repository (fetch)\n&gt; origin https:\/\/github.com\/Career-Karma-Tutorials\/demo-repository (push)<\/pre><\/div>\n\n\n\n<p>There are two lines of code in our remote record. When we go run <a href=\"https:\/\/careerkarma.com\/blog\/git-pull\/\">git pull<\/a>, <a href=\"https:\/\/careerkarma.com\/blog\/git-fetch\">git fetch<\/a>, git config, <a href=\"https:\/\/careerkarma.com\/blog\/git-push\/\">git push<\/a>, or any other Git command, it will refer to our remote repository called demo-repository.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Error: \u201cfatal: remote origin already exists\u201d<\/h2>\n\n\n\n<p>git remote add origin <a href=\"https:\/\/github.com\/Career-Karma-Tutorials\/demo-repository\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">https:\/\/github.com\/Career-Karma-Tutorials\/demo-repository<\/a><\/p>\n\n\n\n<p>&gt; fatal: remote origin already exists<br><\/p>\n\n\n\n<p>You may have encountered an error \u201cfatal: remote origin already exists\u201d when running the above command. What\u2019s the problem?<br><\/p>\n\n\n\n<p>This error is raised when you try to assign a name to a remote that has already been used inside a local version of a repository.<br><\/p>\n\n\n\n<p>You can resolve this error by using a different name for your new remote. If you are comfortable modifying your existing remote, you can rename or delete the existing remote to free up the name for your new remote.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The git remote add command allows you to add a remote to a Git repository.<br><\/p>\n\n\n\n<p>If you encounter a \u201cfatal\u201d error when running the command, you should choose a name for your new remote or rename or delete the existing remote with the name you want to use.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to start using the git remote add command line operation like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"How to Add a Remote to a Git Repository Have you just started a new Git repository on your local machine? You\u2019ll need to add a remote if you intend on linking it to a remote repository. The git remote add command adds a remote to a Git repository. In this guide, we\u2019re going to&hellip;","protected":false},"author":240,"featured_media":15199,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-19904","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-git"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Coding","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Git Add Remote: A Beginner\u2019s Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Add Remote: A Beginner\u2019s Guide\" \/>\n<meta property=\"og:description\" content=\"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-22T07:45:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:55:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"681\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Git Add Remote: A Beginner\u2019s Guide\",\"datePublished\":\"2020-07-22T07:45:41+00:00\",\"dateModified\":\"2023-12-01T11:55:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\"},\"wordCount\":567,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\",\"name\":\"Git Add Remote: A Beginner\u2019s Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg\",\"datePublished\":\"2020-07-22T07:45:41+00:00\",\"dateModified\":\"2023-12-01T11:55:31+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/git-add-remote\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg\",\"width\":1020,\"height\":681,\"caption\":\"A person working on a computer\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-add-remote\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coding\",\"item\":\"https:\/\/careerkarma.com\/blog\/code\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git Add Remote: A Beginner\u2019s Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git Add Remote: A Beginner\u2019s Guide | Career Karma","description":"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.","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:\/\/careerkarma.com\/blog\/git-add-remote\/","og_locale":"en_US","og_type":"article","og_title":"Git Add Remote: A Beginner\u2019s Guide","og_description":"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.","og_url":"https:\/\/careerkarma.com\/blog\/git-add-remote\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-22T07:45:41+00:00","article_modified_time":"2023-12-01T11:55:31+00:00","og_image":[{"width":1020,"height":681,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Git Add Remote: A Beginner\u2019s Guide","datePublished":"2020-07-22T07:45:41+00:00","dateModified":"2023-12-01T11:55:31+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/"},"wordCount":567,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/git-add-remote\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/","url":"https:\/\/careerkarma.com\/blog\/git-add-remote\/","name":"Git Add Remote: A Beginner\u2019s Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg","datePublished":"2020-07-22T07:45:41+00:00","dateModified":"2023-12-01T11:55:31+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The git remote add command adds a link to a remote repository to your local version of a project. On Career Karma, learn how to use the git remote add command.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/git-add-remote\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/woman-using-macbook-pro-1181278.jpg","width":1020,"height":681,"caption":"A person working on a computer"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/git-add-remote\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Coding","item":"https:\/\/careerkarma.com\/blog\/code\/"},{"@type":"ListItem","position":3,"name":"Git Add Remote: A Beginner\u2019s Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19904"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19904\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15199"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}