{"id":9345,"date":"2021-11-25T16:55:17","date_gmt":"2021-11-25T11:25:17","guid":{"rendered":"https:\/\/www.csestack.org\/?p=9345"},"modified":"2021-11-25T16:55:19","modified_gmt":"2021-11-25T11:25:19","slug":"remove-files-from-git-commit-reset-command","status":"publish","type":"post","link":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/","title":{"rendered":"Remove Files from Git Commit using Reset Command"},"content":{"rendered":"\n<p>Git is the most popular source code management tool. If you are new to the git I would recomment you to go through the <a href=\"https:\/\/www.csestack.org\/git\/\">complete Git turorial<\/a>.<\/p>\n\n\n\n<p>In this turorial I&#8217;m going to share simple trick to reset or remove file from git commit. Let&#8217;s see.<\/p>\n\n\n\n<p>I&#8217;m sure you will find this simple command very handy and useful while working on projects.<\/p>\n\n\n\n<p><strong>How to remove files from git commit?<\/strong><\/p>\n\n\n\n<p>If you have added any unwanted or wrong files to the git commit, no worries. This happens and we do make mistakes. You can remove any file that has been added to the commit. <\/p>\n\n\n\n<p>Use git reset command where you have to provide filename with complete directory path.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git reset HEAD path\/to\/file<\/pre>\n\n\n\n<p><strong>Note:<\/strong> This command will not work if you have already pushed the code to your repository. It means you can not revert the chnages once changes are already pushed. In that case, you have to <a href=\"https:\/\/www.csestack.org\/git\/#Step_7_Git_Commit_Commit_All_the_Changes\">revert the git commit<\/a>.<\/p>\n\n\n\n<p>Any query? Let me know in the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to remove files from git commit? Simple git reset command.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[343],"tags":[344],"class_list":["post-9345","post","type-post","status-publish","format-standard","hentry","category-git","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Remove Files from Git Commit using Reset Command<\/title>\n<meta name=\"description\" content=\"How to remove files from git commit? Simple git reset 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:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Remove Files from Git Commit using Reset Command\" \/>\n<meta property=\"og:description\" content=\"How to remove files from git commit? Simple git reset command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/\" \/>\n<meta property=\"og:site_name\" content=\"CSEstack\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/aniruddha.ca\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/aniruddha.ca\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-25T11:25:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-25T11:25:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.csestack.org\/wp-content\/uploads\/2024\/01\/csestack-blog.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Aniruddha Chaudhari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ani_chaudhari\" \/>\n<meta name=\"twitter:site\" content=\"@ani_chaudhari\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aniruddha Chaudhari\" \/>\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:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/\"},\"author\":{\"name\":\"Aniruddha Chaudhari\",\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#\\\/schema\\\/person\\\/634ef1a9c4f38b0d340c6d45fa771218\"},\"headline\":\"Remove Files from Git Commit using Reset Command\",\"datePublished\":\"2021-11-25T11:25:17+00:00\",\"dateModified\":\"2021-11-25T11:25:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/\"},\"wordCount\":177,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#\\\/schema\\\/person\\\/634ef1a9c4f38b0d340c6d45fa771218\"},\"keywords\":[\"git\"],\"articleSection\":[\"git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/\",\"url\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/\",\"name\":\"Remove Files from Git Commit using Reset Command\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#website\"},\"datePublished\":\"2021-11-25T11:25:17+00:00\",\"dateModified\":\"2021-11-25T11:25:19+00:00\",\"description\":\"How to remove files from git commit? Simple git reset command.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.csestack.org\\\/remove-files-from-git-commit-reset-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.csestack.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Remove Files from Git Commit using Reset Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#website\",\"url\":\"https:\\\/\\\/www.csestack.org\\\/\",\"name\":\"CSEstack\",\"description\":\"Computer Science &amp; Programming Portal\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#\\\/schema\\\/person\\\/634ef1a9c4f38b0d340c6d45fa771218\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.csestack.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.csestack.org\\\/#\\\/schema\\\/person\\\/634ef1a9c4f38b0d340c6d45fa771218\",\"name\":\"Aniruddha Chaudhari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.csestack.org\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Aniruddha-Chaudhari.jpg\",\"url\":\"https:\\\/\\\/www.csestack.org\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Aniruddha-Chaudhari.jpg\",\"contentUrl\":\"https:\\\/\\\/www.csestack.org\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Aniruddha-Chaudhari.jpg\",\"width\":634,\"height\":634,\"caption\":\"Aniruddha Chaudhari\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.csestack.org\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Aniruddha-Chaudhari.jpg\"},\"description\":\"I am a Python enthusiast who loves Linux and Vim. I hold a Master of Computer Science degree from NIT Trichy and have 10 years of experience in the IT industry, focusing on the Software Development Lifecycle from Requirements Gathering, Design, Development to Deployment. I have worked at IBM, Ericsson, and NetApp, and I share my knowledge on CSEstack.org.\",\"sameAs\":[\"https:\\\/\\\/www.csestack.org\",\"https:\\\/\\\/www.facebook.com\\\/aniruddha.ca\",\"pythonwithani\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/aniruddha28\\\/\",\"https:\\\/\\\/x.com\\\/ani_chaudhari\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCw0a__B0eJsvCujkSIfLTAA\"],\"url\":\"https:\\\/\\\/www.csestack.org\\\/author\\\/anicse\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Remove Files from Git Commit using Reset Command","description":"How to remove files from git commit? Simple git reset 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:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/","og_locale":"en_US","og_type":"article","og_title":"Remove Files from Git Commit using Reset Command","og_description":"How to remove files from git commit? Simple git reset command.","og_url":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/","og_site_name":"CSEstack","article_publisher":"https:\/\/www.facebook.com\/aniruddha.ca","article_author":"https:\/\/www.facebook.com\/aniruddha.ca","article_published_time":"2021-11-25T11:25:17+00:00","article_modified_time":"2021-11-25T11:25:19+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.csestack.org\/wp-content\/uploads\/2024\/01\/csestack-blog.jpg","type":"image\/jpeg"}],"author":"Aniruddha Chaudhari","twitter_card":"summary_large_image","twitter_creator":"@ani_chaudhari","twitter_site":"@ani_chaudhari","twitter_misc":{"Written by":"Aniruddha Chaudhari","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/#article","isPartOf":{"@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/"},"author":{"name":"Aniruddha Chaudhari","@id":"https:\/\/www.csestack.org\/#\/schema\/person\/634ef1a9c4f38b0d340c6d45fa771218"},"headline":"Remove Files from Git Commit using Reset Command","datePublished":"2021-11-25T11:25:17+00:00","dateModified":"2021-11-25T11:25:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/"},"wordCount":177,"commentCount":0,"publisher":{"@id":"https:\/\/www.csestack.org\/#\/schema\/person\/634ef1a9c4f38b0d340c6d45fa771218"},"keywords":["git"],"articleSection":["git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/","url":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/","name":"Remove Files from Git Commit using Reset Command","isPartOf":{"@id":"https:\/\/www.csestack.org\/#website"},"datePublished":"2021-11-25T11:25:17+00:00","dateModified":"2021-11-25T11:25:19+00:00","description":"How to remove files from git commit? Simple git reset command.","breadcrumb":{"@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.csestack.org\/remove-files-from-git-commit-reset-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.csestack.org\/"},{"@type":"ListItem","position":2,"name":"Remove Files from Git Commit using Reset Command"}]},{"@type":"WebSite","@id":"https:\/\/www.csestack.org\/#website","url":"https:\/\/www.csestack.org\/","name":"CSEstack","description":"Computer Science &amp; Programming Portal","publisher":{"@id":"https:\/\/www.csestack.org\/#\/schema\/person\/634ef1a9c4f38b0d340c6d45fa771218"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.csestack.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.csestack.org\/#\/schema\/person\/634ef1a9c4f38b0d340c6d45fa771218","name":"Aniruddha Chaudhari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.csestack.org\/wp-content\/uploads\/2019\/03\/Aniruddha-Chaudhari.jpg","url":"https:\/\/www.csestack.org\/wp-content\/uploads\/2019\/03\/Aniruddha-Chaudhari.jpg","contentUrl":"https:\/\/www.csestack.org\/wp-content\/uploads\/2019\/03\/Aniruddha-Chaudhari.jpg","width":634,"height":634,"caption":"Aniruddha Chaudhari"},"logo":{"@id":"https:\/\/www.csestack.org\/wp-content\/uploads\/2019\/03\/Aniruddha-Chaudhari.jpg"},"description":"I am a Python enthusiast who loves Linux and Vim. I hold a Master of Computer Science degree from NIT Trichy and have 10 years of experience in the IT industry, focusing on the Software Development Lifecycle from Requirements Gathering, Design, Development to Deployment. I have worked at IBM, Ericsson, and NetApp, and I share my knowledge on CSEstack.org.","sameAs":["https:\/\/www.csestack.org","https:\/\/www.facebook.com\/aniruddha.ca","pythonwithani","https:\/\/www.linkedin.com\/in\/aniruddha28\/","https:\/\/x.com\/ani_chaudhari","https:\/\/www.youtube.com\/channel\/UCw0a__B0eJsvCujkSIfLTAA"],"url":"https:\/\/www.csestack.org\/author\/anicse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/posts\/9345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/comments?post=9345"}],"version-history":[{"count":2,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/posts\/9345\/revisions"}],"predecessor-version":[{"id":9347,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/posts\/9345\/revisions\/9347"}],"wp:attachment":[{"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/media?parent=9345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/categories?post=9345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.csestack.org\/wp-json\/wp\/v2\/tags?post=9345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}