{"id":19011,"date":"2020-10-13T13:29:29","date_gmt":"2020-10-13T13:29:29","guid":{"rendered":"http:\/\/www.devopsschool.com\/blog\/?p=19011"},"modified":"2021-10-29T06:01:52","modified_gmt":"2021-10-29T06:01:52","slug":"how-to-overwrite-local-files-with-git-pull","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-overwrite-local-files-with-git-pull\/","title":{"rendered":"How to Overwrite Local Files with Git Pull."},"content":{"rendered":"\n<p>If you feel the need to discard all your local changes and just reset\/overwrite everything with a copy from the remote branch, then you should follow this guide.<\/p>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-red-color\">Important<\/span><\/strong>: If you have any <strong>local <\/strong>changes, they will be <strong>lost<\/strong>. With or <strong>without <\/strong>&#8211;hard option, any local <strong>commits <\/strong>that haven\u2019t been pushed will be lost.<\/p>\n\n\n\n<p>If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected.<\/p>\n\n\n\n<p>The Overwrite workflow:<br>To overwrite your local files do:<\/p>\n\n\n\n<p><code><strong>git fetch --all<\/strong><br><strong>git reset --hard<\/strong> &lt;remote&gt;\/&lt;branch_name&gt;<\/code><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p><strong><code>git fetch --all<\/code><\/strong><br><code><strong>git reset --hard origin\/master<\/strong><\/code><\/p>\n\n\n\n<p>This will give message like below <\/p>\n\n\n\n<p><strong>HEAD is now at f2**a6* adding last_commit_name<\/strong><\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n\n\n\n<p>Keep Coding.<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_76091\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_72973\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_76091\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>If you feel the need to discard all your local changes and just reset\/overwrite everything with a copy from the remote branch, then you should follow this guide. Important: If you have any local changes, they will be lost. With or without &#8211;hard option, any local commits that haven\u2019t been pushed will be lost. If&#8230;<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[38],"tags":[4849,2568,1573,160,5020],"class_list":["post-19011","post","type-post","status-publish","format-standard","hentry","category-git","tag-advantages-of-git","tag-bash-aliases-for-git","tag-basics-of-git","tag-git","tag-git-commit"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/19011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=19011"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/19011\/revisions"}],"predecessor-version":[{"id":24522,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/19011\/revisions\/24522"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=19011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=19011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=19011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}