{"id":3587,"date":"2022-12-05T10:08:15","date_gmt":"2022-12-05T10:08:15","guid":{"rendered":"https:\/\/gitprotect.io\/blog\/?p=3587"},"modified":"2024-12-11T08:43:55","modified_gmt":"2024-12-11T08:43:55","slug":"git-head-git-head-reset-and-git-head-overwrite-what-to-do","status":"publish","type":"post","link":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/","title":{"rendered":"Git HEAD &#8211; Git HEAD reset and Git HEAD overwrite &#8211; what to do?"},"content":{"rendered":"\n<p>There is a great variety of DevOps tools that serve different purposes and uses. We benefit from them in a number of situations, but sometimes they still can cause some problems. Do you agree with this suggestion, don&#8217;t you?<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>After all, a tool only has certain characteristics and functionalities, but we are the ones who use it in some way or another. We are the ones who decide for which purposes to use a hammer \u2013 to break a window or put a nail into the wall. Let&#8217;s not blame the tools, but rather look at ourselves to see if we are using them correctly!<\/p>\n\n\n\n<p>In the IT world, we use a variety of tools for our daily work, so let&#8217;s take this lesson to ourselves. It&#8217;s not the tool that can spoil the results of our work, but we are, when we use them in a wrong way. And that&#8217;s what this material is about \u2013 how managing <a href=\"https:\/\/gitprotect.io\/blog\/git-commands-list-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">Git commands<\/a> we can get rid of the results of our work by carelessly using something called a HEAD.<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Let&#8217;s dive into Git HEAD<\/strong><\/h2>\n\n\n\n<p>Let\u2019s first briefly discuss what a branch is in Git. How does it work? The ability to branch a project is crucial to modern Version Control Systems. Among other things, Git has gained immense popularity because it allows users to switch between different versions of a project very easily and quickly. This is a vital thing in modern projects.<\/p>\n\n\n\n<p>The solution to this problem in Git deserves applause. The branch in Git does not track the entire version of the project, but only individual changes. If we change only one file in the project then the others are not saved again. Instead, Git tracks a reference to the previous version. To be even more precise, it is not the branch that holds such information, but the commits. The commits are the ones that contain any new, deleted, or edited files. They are permanent and immutable. Moreover, they create a linear history of the project, so we can roll back to any version of the file from the past.<\/p>\n\n\n\n<p>And what does a branch have to do with it? This is where the cleverness of this solution reveals itself. Why? Because a branch simply points to a specific commit, for example, the latest commit on the main branch. Thus, the branch itself is just a simple little file, containing the SHA code of a particular commit. Changing of this pointer is very fast, because it doesn\u2019t reload our entire project, but only jumps to another commit. This allows us to add or remove branches according to our desire. We can even have several branches pointing to the same commit! Why not? By the way, it\u2019s quite common.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Git HEAD<\/h3>\n\n\n\n<p>And what is the HEAD itself? It\u2019s a special indicator that shows the current master branch by default. The one you are currently on and what version of the project you see on the screen. Though, remember that there is only one HEAD indicator in the whole project!<\/p>\n\n\n\n<p>So, a Git branch is a pointer to a commit, and HEAD is a pointer to a branch, that\u2019s how we can think of it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Displaying HEAD information<\/h2>\n\n\n\n<p>Well, let&#8217;s go further and explain how to <a href=\"https:\/\/gitprotect.io\/blog\/automate-devops-tasks-devops-should-automate\/\" target=\"_blank\" rel=\"noreferrer noopener\">check<\/a> what HEAD is pointing to in our project. We can do it in many ways, for example, modern IDEs always mark a branch in a graphical way, in the CLI we can display our Git status and also graphically see where this special indicator is. But there is another way, which does not require our observation skills. We can simply look in the <strong><em>.git<\/em><\/strong> directory in our project and find the file named <strong><em>HEAD <\/em><\/strong>there. Or execute a simple command that will show us its contents:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat .git\/HEAD&nbsp;<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git rev-parse HEAD<\/code><\/pre>\n\n\n\n<p>There we will find one line that can tell us which branch (or commit) the HEAD is currently pointing to, for example something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ref: refs\/heads\/develop<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Git reset HEAD&nbsp;<\/h2>\n\n\n\n<p>Well, we have already cleared out what a branch is, how it works, and what a HEAD is. And what does it give us? Let\u2019s further explain the state we call \u201cdetached HEAD\u201d. In short, it is a state in which our HEAD does not point to any existing branch, but directly to a given commit. This is not a wrong action, sometimes it is expected and we intentionally take such a step. However, we must remember that this leads to a high risk of losing a previous commit or some of them.<\/p>\n\n\n\n<p>Let\u2019s imagine a situation where, after executing one or more commits, we find that we want to roll back to the previous version and continue working from a new starting point. We can use the Git <strong>reset<\/strong> command for this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset HEAD^<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center\">or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset &lt;commit hash&gt;<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-left\">The above command rolls us back one commit backward (HEAD^) or to any indicated commit. This means that our HEAD points to the new location. There are several dangers associated with the Git reset command. The first is that this command allows us to change history, which is not allowed in Git. If we \u201cdelete\u201d a commit already existing in an external git repository, we will not be able to perform a push operation, because of the inconsistency. Never modify an already existing commit history!<\/p>\n\n\n\n<p>Though, it\u2019s worth remembering that we must be careful with this command. Git reset command can work in 3 different ways: git reset &#8211;soft, git reset &#8211;mixed, and git reset &#8211;hard commands. Using one or another we can delete (or keep) changes from the working directory or staging area.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Git reset &#8211;soft HEAD<\/h3>\n\n\n\n<p>The purpose of the &#8211;soft reset command is to update the reference to a certain commit in the HEAD, where the most recent commit is located on your local system. For example, if you notice that some file to a commit is missing (maybe you forgot to add it), you can use the &#8211;soft command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --soft HEAD~n<\/code><\/pre>\n\n\n\n<p>This soft reset command will allow you to move back to the specific commit. Under n, we mean specific reference. For example, if you want to get back to the last commit, you can use git reset &#8211;soft HEAD~1.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --soft &lt;commit ID&gt;<\/code><\/pre>\n\n\n\n<p>With the following command, you can move back to the HEAD with the &lt;commit ID&gt;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Git reset &#8211;mixed<\/h3>\n\n\n\n<p>Being a default argument for git reset, git reset &#8211;mixed can have two impacts. They are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>uncommitting all the changes,<\/li>\n\n\n\n<li>unstaging all the changes.<\/li>\n<\/ul>\n\n\n\n<p>You can use this command, for example, if you accidentally added a file and you need to remove it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Git rest &#8211;hard<\/h3>\n\n\n\n<p>You should remember that git reset &#8211;hard is a potentially dangerous command. If you use this command on a certain commit, it forces the HEAD to go back to that specific commit. Moreover, it deletes everything after that commit and permanently discards uncommitted changes, and updates the working directory, index, and HEAD.<\/p>\n\n\n\n<p>In contrast, &#8216;git checkout&#8217; only updates the HEAD pointer without altering the current branch, making it a safer option for switching branches. To understand it more I recommend reading the article <a href=\"https:\/\/gitprotect.io\/blog\/how-to-undo-a-commit-in-git\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to undo a commit in Git<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Git HEAD overwrite<\/h2>\n\n\n\n<p>But modifying the history (and all the implications of that) is just one part of the story. Let\u2019s assume we\u2019re only doing this on local changes, intentionally, and we <a href=\"https:\/\/gitprotect.io\/blog\/cloud-security-and-privacy-best-practices-to-mitigate-the-risks\/\" target=\"_blank\" rel=\"noreferrer noopener\">know<\/a> we\u2019re not messing anything up, in terms of the commit history. Is there any other risk then? Of course. Though I must admit that this is a rather unusual situation, it is not completely rare.<\/p>\n\n\n\n<p>If we use the Git reset command to roll back to a specific commit (to which no branch is pointing) then we will have the situation described earlier \u2013 the so-called \u201cdetached HEAD\u201d. To reset the HEAD pointer to a specific commit, you can use the git reset HEAD command. From here, of course, we can make further changes and save them in new commits. At first glance, everything works normally, the changes have been added, the commit saved, we can even use the git log command and trace our new history.<\/p>\n\n\n\n<p>However, there may be a problem when we need to switch to a certain branch for some reason. For example, we want to add the current version from develop to what we\u2019ve just coded. We switch to the develop branch, download the new changes, if any, and\u2026 we don\u2019t know how to get back to our just-written code, because we didn\u2019t add any branch there. Well, we just lost some part of our work.<\/p>\n\n\n\n<p>We can see it in the image below. Starting with the <strong>develop<\/strong> branch, we created a new branch \u2013 <strong>featureX<\/strong>, and then added 3 commits. However, we found that some changes needed to be rolled back and another solution is expected. The \u201c<strong>git reset C2\u201d<\/strong> operation rolled back our HEAD to commit C2, at the same time transitioning to a \u201cdetached HEAD\u201d state. At this point, we made further changes but still remained in this state. When we switch to the <strong>develop<\/strong> branch, it is almost impossible to recover the changes contained in commits C5 and C6.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"488\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5-1024x488.png\" alt=\"Git HEAD overwrite\" class=\"wp-image-5983\" style=\"width:500px;height:auto\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5-1024x488.png 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5-300x143.png 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5-768x366.png 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5-400x191.png 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/image1-5.png 1349w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">The importance of a backup<\/h2>\n\n\n\n<p class=\"has-background\" style=\"background:linear-gradient(135deg,rgb(244,250,254) 0%,rgb(244,250,254) 100%)\">Overwriting can be a serious issue. There are a few more methods at your disposal \u2013 starting with the <a href=\"https:\/\/gitprotect.io\/blog\/git-revert-file-to-previous-commit\/\" target=\"_blank\" rel=\"noreferrer noopener\">git revert<\/a> command and so on. However, if you are interested in a more automatic approach \u2013 try a backup. A dedicated <a href=\"https:\/\/gitprotect.io\/azure-devops-backup.html\" target=\"_blank\" rel=\"noreferrer noopener\">DevOps backup<\/a> is a good option especially if you need comprehensive <a href=\"https:\/\/gitprotect.io\/blog\/devsecops-way-to-improve-source-code-protection-quality-visibility-monitoring-and-compliance\/\" target=\"_blank\" rel=\"noreferrer noopener\">code protection<\/a> \u2013 automatic backup\/backup on demand, unlimited retention, disaster recovery, etc. <a href=\"https:\/\/gitprotect.io\/git-backup-guide.html\" target=\"_blank\" rel=\"noreferrer noopener\">Check our guide<\/a> to find out more about the <a href=\"https:\/\/gitprotect.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">git backup<\/a> best practices. And if you have only a handful repos to secure? Well, PRO solutions have also free tiers \u2013 with <a href=\"https:\/\/gitprotect.io\/features.html\" target=\"_blank\" rel=\"noreferrer noopener\">GitProtect<\/a> you can backup up to 15 git repositories for free. Grab <a href=\"https:\/\/github.com\/marketplace\/gitprotect-io\" target=\"_blank\" rel=\"noreferrer noopener\">our app in the Marketplace<\/a> and check it out yourself.<\/p>\n\n\n\n<p>As I mentioned, this is a rather rare situation, mostly due to the programmer&#8217;s lack of attention. But after all, so-called human error is one of the main causes of our problems, so we should try to minimize it wherever possible. Maybe such a situation will not cause a catastrophe in our project, but let&#8217;s act here according to one of the lean principles \u2013 the pursuit of perfection. The company should find ways to get a little better all the time. So let&#8217;s implement it. Let&#8217;s take care of proper and regular backups to be prepared even for these rather rare situations, leading to data loss.<\/p>\n\n\n\n<p>For this reason, you can organize your backup by yourself \u2013 delegate some developer of your team to write scripts, perform those backups, check their performance, and if it&#8217;s needed write a recovery script to <a href=\"https:\/\/gitprotect.io\/faq\/how-can-i-restore-data.html\" target=\"_blank\" rel=\"noreferrer noopener\">restore the data<\/a>. Though, from one side it&#8217;s time-consuming, and, from the other, ineffective, as it will distract your DevOps from their core duties.&nbsp;<\/p>\n\n\n\n<p>On the other hand, you can build a backup strategy using <a href=\"https:\/\/gitprotect.io\/blog\/do-you-think-that-your-git-repositories-are-secure\/\" target=\"_blank\" rel=\"noreferrer noopener\">third-party<\/a> backup tools, like GitProtect.io. Will it benefit your development process? Let&#8217;s see, backup software can bring automation into your coding \u2013 all your data will be backed up according to your custom settings automatically, saving your DevOps time. Moreover, a comprehensive backup solution will guarantee your data to be accessible and recoverable from any point in time, which eliminates data losses in case of human errors or other events of failure.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#f4fafe\"><a href=\"https:\/\/gitprotect.io\/sign-up.html\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>[FREE TRIAL] Ensure compliant DevOps backup and recovery with a 14-day trial<\/strong><\/a><strong>\ud83d\ude80<\/strong><br><br><a href=\"https:\/\/calendly.com\/d\/3s9-n9z-pgc\/gitprotect-live-demo?month=2024-11\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>[CUSTOM DEMO] Let\u2019s talk about how backup &amp; DR software for DevOps stack can help you mitigate the risks<\/strong><\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a great variety of DevOps tools that serve different purposes and uses. We benefit from them in a number of situations, but sometimes they still can cause some problems. Do you agree with this suggestion, don&#8217;t you?<\/p>\n","protected":false},"author":6,"featured_media":3597,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3587","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git-backup-101","post--single"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io\" \/>\n<meta property=\"og:description\" content=\"There is a great variety of DevOps tools that serve different purposes and uses. We benefit from them in a number of situations, but sometimes they still can cause some problems. Do you agree with this suggestion, don&#8217;t you?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog | GitProtect.io\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/XoperoSoftware\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-05T10:08:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-11T08:43:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tomasz Lisowski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:site\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tomasz Lisowski\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\"},\"author\":{\"name\":\"Tomasz Lisowski\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/9437be55e0e82150a20247f63e2fef79\"},\"headline\":\"Git HEAD &#8211; Git HEAD reset and Git HEAD overwrite &#8211; what to do?\",\"datePublished\":\"2022-12-05T10:08:15+00:00\",\"dateModified\":\"2024-12-11T08:43:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\"},\"wordCount\":1936,\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg\",\"articleSection\":[\"Git Backup 101\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\",\"name\":\"Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg\",\"datePublished\":\"2022-12-05T10:08:15+00:00\",\"dateModified\":\"2024-12-11T08:43:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg\",\"width\":1200,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\/\/gitprotect.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git HEAD &#8211; Git HEAD reset and Git HEAD overwrite &#8211; what to do?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"name\":\"GitProtect.io Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/gitprotect.io\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\",\"name\":\"GitProtect.io\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"width\":528,\"height\":528,\"caption\":\"GitProtect.io\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/XoperoSoftware\/\",\"https:\/\/x.com\/GitProtectio\",\"https:\/\/www.linkedin.com\/company\/xopero-software\/\",\"https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/9437be55e0e82150a20247f63e2fef79\",\"name\":\"Tomasz Lisowski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/tomasz-lisowski_avatar-96x96.jpg\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/tomasz-lisowski_avatar-96x96.jpg\",\"caption\":\"Tomasz Lisowski\"},\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/tomasz-lisowski-01366a75\/\"],\"url\":\"https:\/\/gitprotect.io\/blog\/author\/tomasz-lisowski\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io","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:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/","og_locale":"en_US","og_type":"article","og_title":"Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io","og_description":"There is a great variety of DevOps tools that serve different purposes and uses. We benefit from them in a number of situations, but sometimes they still can cause some problems. Do you agree with this suggestion, don&#8217;t you?","og_url":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/","og_site_name":"Blog | GitProtect.io","article_publisher":"https:\/\/www.facebook.com\/XoperoSoftware\/","article_published_time":"2022-12-05T10:08:15+00:00","article_modified_time":"2024-12-11T08:43:55+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg","type":"image\/jpeg"}],"author":"Tomasz Lisowski","twitter_card":"summary_large_image","twitter_creator":"@GitProtectio","twitter_site":"@GitProtectio","twitter_misc":{"Written by":"Tomasz Lisowski","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#article","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/"},"author":{"name":"Tomasz Lisowski","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/9437be55e0e82150a20247f63e2fef79"},"headline":"Git HEAD &#8211; Git HEAD reset and Git HEAD overwrite &#8211; what to do?","datePublished":"2022-12-05T10:08:15+00:00","dateModified":"2024-12-11T08:43:55+00:00","mainEntityOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/"},"wordCount":1936,"publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg","articleSection":["Git Backup 101"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/","url":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/","name":"Git HEAD - Git HEAD reset and Git HEAD overwrite - what to do? - Blog | GitProtect.io","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg","datePublished":"2022-12-05T10:08:15+00:00","dateModified":"2024-12-11T08:43:55+00:00","breadcrumb":{"@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#primaryimage","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/12\/Git-HEAD_blog-1.jpg","width":1200,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/gitprotect.io\/blog\/git-head-git-head-reset-and-git-head-overwrite-what-to-do\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/gitprotect.io\/blog\/"},{"@type":"ListItem","position":2,"name":"Git HEAD &#8211; Git HEAD reset and Git HEAD overwrite &#8211; what to do?"}]},{"@type":"WebSite","@id":"https:\/\/gitprotect.io\/blog\/#website","url":"https:\/\/gitprotect.io\/blog\/","name":"GitProtect.io Blog","description":"","publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gitprotect.io\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/gitprotect.io\/blog\/#organization","name":"GitProtect.io","url":"https:\/\/gitprotect.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","width":528,"height":528,"caption":"GitProtect.io"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/XoperoSoftware\/","https:\/\/x.com\/GitProtectio","https:\/\/www.linkedin.com\/company\/xopero-software\/","https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w"]},{"@type":"Person","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/9437be55e0e82150a20247f63e2fef79","name":"Tomasz Lisowski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/tomasz-lisowski_avatar-96x96.jpg","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/tomasz-lisowski_avatar-96x96.jpg","caption":"Tomasz Lisowski"},"sameAs":["https:\/\/www.linkedin.com\/in\/tomasz-lisowski-01366a75\/"],"url":"https:\/\/gitprotect.io\/blog\/author\/tomasz-lisowski\/"}]}},"_links":{"self":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/3587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/comments?post=3587"}],"version-history":[{"count":14,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/3587\/revisions"}],"predecessor-version":[{"id":6078,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/3587\/revisions\/6078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media\/3597"}],"wp:attachment":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media?parent=3587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/categories?post=3587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/tags?post=3587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}