{"id":548,"date":"2009-05-18T10:12:03","date_gmt":"2009-05-18T15:12:03","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/poojanblog\/?p=548"},"modified":"2009-06-23T18:47:29","modified_gmt":"2009-06-23T23:47:29","slug":"how-not-to-go-back-in-time-using-git-equivalent-of-svn-revert","status":"publish","type":"post","link":"https:\/\/poojanblog.com\/blog\/2009\/05\/how-not-to-go-back-in-time-using-git-equivalent-of-svn-revert\/","title":{"rendered":"How not to go back in time using git (equivalent of svn revert)"},"content":{"rendered":"<p>Update: I recovered my lost commit by following the directions <a href=\"http:\/\/stackoverflow.com\/questions\/5473\/undoing-a-git-reset-hard-head1\">here<\/a>. In addition, I had to create a branch from this commit using <code>chekcout -b<\/code>. I then switch to the <code>master<\/code> branch and merged the temporary branch into <code>master<\/code><\/p>\n<p>It has been <a href=\"http:\/\/bryan-murdock.blogspot.com\/2007\/07\/git-revert-is-not-equivalent-to-svn.html\"><del datetime=\"2009-05-18T14:58:47+00:00\">written<\/del> posted<\/a> that <code>git revert<\/code> is not the same as <code>svn revert<\/code>. That&#8217;s true.<\/p>\n<p>However, there have been suggestions that the equivalent is <code>git reset --hard <\/code><em>commit<\/em>. I just did this. It isn&#8217;t good. Luckily, I didn&#8217;t lose <del datetime=\"2009-05-18T16:22:51+00:00\">much<\/del>any data. However, doing a <code>--hard<\/code> means that you <em>reset the index<\/em> back in time, too&#8211;not just your working copy.<\/p>\n<p>I&#8217;ll admit that I don&#8217;t understand git very well. I&#8217;m not entirely sure (now that I&#8217;ve gone back in time) how to bring myself back to the future.<\/p>\n<p>Essentially <code>git reset<\/code> means that you want to get rid of changes in your repository: not merely go back in time, see what things looked like, and move forward in time.<\/p>\n<p>Anyway, a safer thing (for me to have done) would be <code>git checkout <\/code><em>commit<\/em>.<\/p>\n<p>The git manual specifically says:<\/p>\n<blockquote><p>&#8211;hard<\/p>\n<p>Matches the working tree and index to that of the tree being switched to. <strong>Any changes to tracked files in the working tree since <em>commit<\/em> are lost.<\/strong><\/p><\/blockquote>\n<p>Wonder if I&#8217;m too feeble to be <a title=\"Git as MacGyver; Mercurial as James Bond\" href=\"http:\/\/importantshock.wordpress.com\/2008\/08\/07\/git-vs-mercurial\/\" target=\"_blank\">MacGyver and need a James Bond<\/a>. On the other hand, now that I&#8217;ve learned this lesson, maybe I&#8217;m better off sticking here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There have been suggestions that the equivalent is <code>git reset --hard <\/code><em>commit<\/em>. I just did this. It isn&#8217;t good. Luckily, I didn&#8217;t lose much data. However, doing a <code>--hard<\/code> means that you <em>reset the index<\/em> back in time, too&#8211;not just your working copy.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[31],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-desktop-computing","tag-git"],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=548"}],"version-history":[{"count":12,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/548\/revisions"}],"predecessor-version":[{"id":600,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/548\/revisions\/600"}],"wp:attachment":[{"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}