{"id":24343,"date":"2020-10-15T11:57:26","date_gmt":"2020-10-15T18:57:26","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=24343"},"modified":"2020-10-15T11:57:28","modified_gmt":"2020-10-15T18:57:28","slug":"error-git-overwritten-by-checkout","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/","title":{"rendered":"Git Error: untracked files would be overwritten by checkout"},"content":{"rendered":"\n<p>While using git to keep track of your changes in your project, many things can happen that cause an error. When you move from one branch to another, you might get this error:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>error: the following untracked working tree files would be overwritten by checkout\n\n[ List of Files Here ]\n\nPlease, commit your changes or stash them before you can switch branches.<\/pre><\/div>\n\n\n\n<p>This error occurs when you have files that are on the current branch that have changes on the branch you are working on as well. The fix is fairly simple: do exactly what the last statement says in the error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Commit Changes<\/h2>\n\n\n\n<p>To commit the changes, you would input the following:\u00a0<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git commit -m &quot;Insert meaningful git commit message here&quot;<\/pre><\/div>\n\n\n\n<p>This should clean out your working tree. And then use <code>git checkout &lt;name-of-branch><\/code> to change branches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Stash Changes<\/h2>\n\n\n\n<p>Use git stash to store your changes until you are ready to commit. Git stash will conserve your changes, but not associate them with any commit or branch until you are ready.&nbsp;<br><\/p>\n\n\n\n<p>To use stash, do the following in your local repository:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git stash push \ngit checkout &lt;branch-you-need-to-switch-to&gt;\n--- do whatever you have to do on &lt;branch-you-need-to-switch-to&gt; ---\ngit checkout &lt;previous-branch&gt;\ngit stash pop <\/pre><\/div>\n\n\n\n<p>If you are familiar with how a stack works, this is straightforward. As a reminder, a stack is a last-in-first-out (LIFO) data structure. The latest stash is added to the end of the list. Pop it off when you are ready to use it.<br><\/p>\n\n\n\n<p>The default behavior is to pop off the last element in the stash list and completely remove it. If you don\u2019t want to get rid of the stash, but simply just use it, you can do that with <code>git stash apply<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article, we looked at two ways to correct an working tree file error that would be overwritten on checkout. Most times, we can do exactly what the git error says to correct it. In this instance, we can either commit the changes or stash the changes to clear the working tree so we can change branches. Which one you decide to do to clear out your error is dependent on what your team\u2019s git workflow is. Always ask for help if you\u2019re unsure of which to do. Happy hacking!<\/p>\n","protected":false},"excerpt":{"rendered":"While using git to keep track of your changes in your project, many things can happen that cause an error. When you move from one branch to another, you might get this error: error: the following untracked working tree files would be overwritten by checkout [ List of Files Here ] Please, commit your changes&hellip;","protected":false},"author":77,"featured_media":19662,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-24343","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 Error: Overwritten Files on Checkout | Career Karma<\/title>\n<meta name=\"description\" content=\"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout 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-overwritten-by-checkout\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Error: untracked files would be overwritten by checkout\" \/>\n<meta property=\"og:description\" content=\"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout on Career Karma!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/\" \/>\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-15T18:57:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-15T18:57:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"676\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"Git Error: untracked files would be overwritten by checkout\",\"datePublished\":\"2020-10-15T18:57:26+00:00\",\"dateModified\":\"2020-10-15T18:57:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/\"},\"wordCount\":328,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/yancy-min-842ofHC6MaI-unsplash.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/\",\"name\":\"Git Error: Overwritten Files on Checkout | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/yancy-min-842ofHC6MaI-unsplash.jpg\",\"datePublished\":\"2020-10-15T18:57:26+00:00\",\"dateModified\":\"2020-10-15T18:57:28+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout on Career Karma!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/yancy-min-842ofHC6MaI-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/yancy-min-842ofHC6MaI-unsplash.jpg\",\"width\":1020,\"height\":676,\"caption\":\"git tree\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/error-git-overwritten-by-checkout\\\/#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 Error: untracked files would be overwritten by checkout\"}]},{\"@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 Error: Overwritten Files on Checkout | Career Karma","description":"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout 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-overwritten-by-checkout\/","og_locale":"en_US","og_type":"article","og_title":"Git Error: untracked files would be overwritten by checkout","og_description":"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout on Career Karma!","og_url":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-15T18:57:26+00:00","article_modified_time":"2020-10-15T18:57:28+00:00","og_image":[{"width":1020,"height":676,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"Git Error: untracked files would be overwritten by checkout","datePublished":"2020-10-15T18:57:26+00:00","dateModified":"2020-10-15T18:57:28+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/"},"wordCount":328,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-unsplash.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/","url":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/","name":"Git Error: Overwritten Files on Checkout | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-unsplash.jpg","datePublished":"2020-10-15T18:57:26+00:00","dateModified":"2020-10-15T18:57:28+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"Learn how to deal with a git error that warns when you have files that will be overwritten by checkout on Career Karma!","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/yancy-min-842ofHC6MaI-unsplash.jpg","width":1020,"height":676,"caption":"git tree"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/error-git-overwritten-by-checkout\/#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 Error: untracked files would be overwritten by checkout"}]},{"@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\/24343","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=24343"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24343\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19662"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=24343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=24343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=24343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}