{"id":24265,"date":"2020-10-14T11:35:29","date_gmt":"2020-10-14T18:35:29","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=24265"},"modified":"2020-12-29T12:11:26","modified_gmt":"2020-12-29T20:11:26","slug":"error-git-refusing-to-merge-unrelated-histories","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/","title":{"rendered":"Git refusing to merge unrelated histories"},"content":{"rendered":"\n<p>There are several places in the git workflow that can cause errors. In this article, we\u2019ll talk about one such error that is confusing to tackle and find a solution to!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Git Error<\/h2>\n\n\n\n<p>The <code>fatal: refusing to merge unrelated histories<\/code> error occurs when you have cloned a project from a git repository and somewhere along the line, that special .git directory is deleted or gets corrupted.&nbsp;<br><\/p>\n\n\n\n<p>This <code>.git<\/code> directory is the way a version control tracks your changes from the remote repository. You can see this directory exists when you input the <code>ls -a<\/code> command in the root directory of your local repository. The list that results has the <code>.git<\/code> directory there.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/xGb-nSyEvUoOgnC7_FFLJFJyyBRZeiHmMdgZ6Au9llGJ6-qA5VF8DwU4Qq1q5R67Rz1DJ3C5NELCBPJRRcQUm_tBGY6GfQtoF76qq-Q6AvehxCSZPmVDNt7HLY8smNGOBOhDZYTR\" alt=\"Directory contents after ls -a\"\/><figcaption> When you use the ls -a command, it will list all files in your directory, including those beginning with \u2018.\u2019.&nbsp; <\/figcaption><\/figure>\n\n\n\n<p>Because the <code>.git<\/code> directory is damaged or deleted, the version control is unaware of your local history and will throw this merge unrelated histories error when you push or pull from the remote repo.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Solution<\/h2>\n\n\n\n<p>Git\u2019s solution for this to pull the remote repo into your project with the escape hatch <code>--allow-unrelated-histories<\/code>.<\/p>\n\n\n\n<p><code>git pull origin master --allow-unrelated-histories<\/code><\/p>\n\n\n\n<p>This allows the two projects to merge with non-matching git history. More information can be found here on <a href=\"https:\/\/github.com\/git\/git\/blob\/master\/Documentation\/RelNotes\/2.9.0.txt#L58-L68\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">Git\u2019s official documentation<\/a>.<br><\/p>\n\n\n\n<p>If you try to push after entering the pull command, you should now be able to do it.<\/p>\n","protected":false},"excerpt":{"rendered":"There are several places in the git workflow that can cause errors. In this article, we\u2019ll talk about one such error that is confusing to tackle and find a solution to! The Git Error The fatal: refusing to merge unrelated histories error occurs when you have cloned a project from a git repository and somewhere&hellip;","protected":false},"author":77,"featured_media":24266,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-24265","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":"Git","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.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Git refusing to merge unrelated histories | Career Karma<\/title>\n<meta name=\"description\" content=\"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!\" \/>\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\/error-git-refusing-to-merge-unrelated-histories\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git refusing to merge unrelated histories\" \/>\n<meta property=\"og:description\" content=\"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/\" \/>\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-10-14T18:35:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-29T20:11:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christina Kopecky\" \/>\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=\"Christina Kopecky\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"Git refusing to merge unrelated histories\",\"datePublished\":\"2020-10-14T18:35:29+00:00\",\"dateModified\":\"2020-12-29T20:11:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/\"},\"wordCount\":223,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/\",\"name\":\"Git refusing to merge unrelated histories | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg\",\"datePublished\":\"2020-10-14T18:35:29+00:00\",\"dateModified\":\"2020-12-29T20:11:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg\",\"width\":1020,\"height\":680,\"caption\":\"Github repository home page\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-refusing-to-merge-unrelated-histories\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git refusing to merge unrelated histories\"}]},{\"@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\\\/ae0cdc4a5d198690d78482646894074e\",\"name\":\"Christina Kopecky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"caption\":\"Christina Kopecky\"},\"description\":\"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.\",\"sameAs\":[\"http:\\\/\\\/www.linkedin.com\\\/in\\\/cmvnk\"],\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/christina-kopecky\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git refusing to merge unrelated histories | Career Karma","description":"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!","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\/error-git-refusing-to-merge-unrelated-histories\/","og_locale":"en_US","og_type":"article","og_title":"Git refusing to merge unrelated histories","og_description":"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!","og_url":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-14T18:35:29+00:00","article_modified_time":"2020-12-29T20:11:26+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg","type":"image\/jpeg"}],"author":"Christina Kopecky","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Christina Kopecky","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"Git refusing to merge unrelated histories","datePublished":"2020-10-14T18:35:29+00:00","dateModified":"2020-12-29T20:11:26+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/"},"wordCount":223,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/","url":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/","name":"Git refusing to merge unrelated histories | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg","datePublished":"2020-10-14T18:35:29+00:00","dateModified":"2020-12-29T20:11:26+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"Learn how to tackle a git error that refuses to allow merging of unrelated histories with this article on Career Karma!","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/markus-winkler-ZDwh_sxsX2g-unsplash.jpg","width":1020,"height":680,"caption":"Github repository home page"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/error-git-refusing-to-merge-unrelated-histories\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Git","item":"https:\/\/careerkarma.com\/blog\/git\/"},{"@type":"ListItem","position":3,"name":"Git refusing to merge unrelated histories"}]},{"@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\/ae0cdc4a5d198690d78482646894074e","name":"Christina Kopecky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","caption":"Christina Kopecky"},"description":"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.","sameAs":["http:\/\/www.linkedin.com\/in\/cmvnk"],"url":"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24265","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\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=24265"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24265\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/24266"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=24265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=24265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=24265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}