Add notes on rewinding bare repositories in Git.
authorW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 00:47:34 +0000 (20:47 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 00:47:34 +0000 (20:47 -0400)
posts/Git/notes.org

index e89f7d1f21d7c5b7e04029e3b939c5e5981ebd11..702b158970f8495571f89fa73d65d5239f5ae039 100644 (file)
@@ -546,6 +546,21 @@ above and try
 
 or add however many =^= you need to get back to the last good commit.
 
+*** Rewinding bare repositories
+
+If you're trying to [[http://stackoverflow.com/questions/4624881/how-can-i-uncommit-the-last-commit-in-a-git-bare-repository][roll back a few commits in a bare repository]]
+you'll need to use:
+
+    : $ git update-ref HEAD HEAD^
+
+If you're in another branch, use:
+
+    : $ git update-ref refs/heads/branch-name branch-name^
+
+And if you're going back further, use the sha1:
+
+    : $ git update-ref refs/heads/branch-name a12d48e2
+
 ** Git submodules, nesting/tracking sub-repositories.
 
 This is a nice way of grouping associated projects.  The submodules