{"id":23005,"date":"2020-09-21T06:24:08","date_gmt":"2020-09-21T13:24:08","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23005"},"modified":"2023-12-01T04:00:14","modified_gmt":"2023-12-01T12:00:14","slug":"git-changes-not-staged-for-commit","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/","title":{"rendered":"Git changes not staged for commit Explanation"},"content":{"rendered":"\n<p>Before you create a commit, you have to add the files you have changed to that commit. When you run the <code>git status<\/code> command before adding files to a commit, you\u2019ll see the <code>changes not staged for commit<\/code> message in the output of the command.<br><\/p>\n\n\n\n<p>In this guide, we\u2019re going to discuss what this message means and why it is important. We\u2019ll walk through an example of how you can stage the files you need to add to a commit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">changes not staged for commit<\/h2>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/what-is-git\/\">Files in a Git repository<\/a> can either be ignored, in the staging area, or part of a commit.<br><\/p>\n\n\n\n<p>Ignored files are not included in the record of a Git repository. Files in the staging area are those that are going to be added to the next commit.<br><\/p>\n\n\n\n<p>The staging area is important because it lets you choose which files should and should not be added to a commit. You can add or remove files from the staging area at any time before you create a commit.<br><\/p>\n\n\n\n<p>This means the staging area is somewhat of a triage space. If you realize an additional file needs to be added into a commit, you can add it to staging. Then, once you are sure you have added all the changes to the staging area, you can create a commit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">An Example Scenario<\/h2>\n\n\n\n<p>To receive this message, we must first change a file in a Git repository. Suppose we have a Git repository with a blank file called README.md. We\u2019re going to change its contents to show the following:<br><\/p>\n\n\n\n<p><code># Example Repo<br><\/code><\/p>\n\n\n\n<p>We have changed a file in our repository. Next, we\u2019re going to run the git status command to view a summary of all the files that have changed:<br><\/p>\n\n\n\n<p><code>git status<br><\/code><\/p>\n\n\n\n<p>Let\u2019s see what this command displays:<br><\/p>\n\n\n\n<p>On branch master<\/p>\n\n\n\n<p>Your branch is up to date with \u2018origin\/master\u2019.<br><\/p>\n\n\n\n<p>Changes not staged for commit:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>(use &quot;git add &lt;file&gt;...&quot; to update what will be committed)\n  (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)\n\n    modified:   README.md\n<\/pre><\/div>\n\n\n\n<p>The Git command line tells us we are viewing the master branch and our current branch is up to date with our remote branch. We have changed one file: README.md. This file has not yet been added to the staging area or a commit. Our working directory is modified.<br><\/p>\n\n\n\n<p>To make this message go away, we have to add the README.md file to the staging area. We can do this using the <a href=\"https:\/\/careerkarma.com\/blog\/git-add\/\">git add command<\/a>:<br><\/p>\n\n\n\n<p><code>git add README.md<br><\/code><\/p>\n\n\n\n<p>This command lets us selectively choose files to add into a commit. Next, we can create a commit with the files we have changed that are currently in the staging area. Let\u2019s run git commit to <a href=\"https:\/\/careerkarma.com\/blog\/git-commit\/\">create a commit<\/a>:<br><\/p>\n\n\n\n<p><code>git commit -m \u201cdocs: Update README.md\u201d<br><\/code><\/p>\n\n\n\n<p>This will create a record of the current state of the repository with all of the changes we\u2019ve added to the staging area. If you are working with a repository with a remote version, you may want to <a href=\"https:\/\/careerkarma.com\/blog\/git-push\/\">push your commit<\/a> to the repository after making it:<br><\/p>\n\n\n\n<p><code>git push<br><\/code><\/p>\n\n\n\n<p>Our change has now been made to both the local and remote versions of our repository.<br><\/p>\n\n\n\n<p>Let\u2019s take a look at the git status on branch again again:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>On branch master\nYour branch is up to date with 'origin\/master'.\n\nnothing to commit, working tree clean\n<\/pre><\/div>\n\n\n\n<p>The command tells us there are no changes that have not been added to a commit or the staging area. This means we have successfully changed our repository. There is now one additional commit in our repository which contains the change we made to README.md.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The \u201cchanges not staged for commit\u201d message shows when you run the \u201cgit status\u201d command and have a file that has been changed but has not yet been added to the staging area.<br><\/p>\n\n\n\n<p>This is not an error message, rather a notification that you have changed files that are not in the staging area or a commit. You can make the message go away by adding your files to a commit and committing them to a repository.<br>Now you have the knowledge you need to fix this Git error like a <a href=\"https:\/\/careerkarma.com\/blog\/what-is-coding-used-for\/\">professional developer<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"Before you create a commit, you have to add the files you have changed to that commit. When you run the git status command before adding files to a commit, you\u2019ll see the changes not staged for commit message in the output of the command. In this guide, we\u2019re going to discuss what this message&hellip;","protected":false},"author":240,"featured_media":23006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-23005","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 changes not staged for commit Explanation | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status 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-changes-not-staged-for-commit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git changes not staged for commit Explanation\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/\" \/>\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-09-21T13:24:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:00:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Git changes not staged for commit Explanation\",\"datePublished\":\"2020-09-21T13:24:08+00:00\",\"dateModified\":\"2023-12-01T12:00:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/\"},\"wordCount\":652,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/chris-ried-3FT0OAPBoKw-unsplash.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/\",\"name\":\"Git changes not staged for commit Explanation | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/chris-ried-3FT0OAPBoKw-unsplash.jpg\",\"datePublished\":\"2020-09-21T13:24:08+00:00\",\"dateModified\":\"2023-12-01T12:00:14+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status command.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/chris-ried-3FT0OAPBoKw-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/chris-ried-3FT0OAPBoKw-unsplash.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-changes-not-staged-for-commit\\\/#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 changes not staged for commit Explanation\"}]},{\"@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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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 changes not staged for commit Explanation | Career Karma","description":"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status 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-changes-not-staged-for-commit\/","og_locale":"en_US","og_type":"article","og_title":"Git changes not staged for commit Explanation","og_description":"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status command.","og_url":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-21T13:24:08+00:00","article_modified_time":"2023-12-01T12:00:14+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Git changes not staged for commit Explanation","datePublished":"2020-09-21T13:24:08+00:00","dateModified":"2023-12-01T12:00:14+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/"},"wordCount":652,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/","url":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/","name":"Git changes not staged for commit Explanation | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.jpg","datePublished":"2020-09-21T13:24:08+00:00","dateModified":"2023-12-01T12:00:14+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn about the cause of the \u201cchanges not staged for commit\u201d message as a response to the git status command.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/chris-ried-3FT0OAPBoKw-unsplash.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/git-changes-not-staged-for-commit\/#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 changes not staged for commit Explanation"}]},{"@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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/23005","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=23005"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/23006"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}