From 925b2975d3a04444f33ae6f0c50a3b59da8d951b Mon Sep 17 00:00:00 2001 From: Ben Lynn Date: Tue, 4 Dec 2007 17:54:59 -0800 Subject: [PATCH] Added HEAD-hunting section --- grandmaster.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grandmaster.txt b/grandmaster.txt index cee7dc9..daf7435 100644 --- a/grandmaster.txt +++ b/grandmaster.txt @@ -91,7 +91,7 @@ Again, only do this if no one else has a clone of your tree. === Local Changes Last === You're working on an active project. You make some local commits over time, and -then you sync with the official tree with a merge. This cycle repeats itself a few times before you're ready to push to the cetnral tree. +then you sync with the official tree with a merge. This cycle repeats itself a few times before you're ready to push to the central tree. But now the history in your local Git clone is a messy jumble of your changes and the official changes. You'd prefer to see all your changes in one contiguous section, and after all the official changes. @@ -117,6 +117,18 @@ But suppose you never took it down? Don't worry, for commands like these, Git sa $ git reset ORIG_HEAD +=== HEAD-hunting === + +Perhaps ORIG_HEAD isn't enough. Perhaps you've just realized you made a monumental mistake last month and you need to go back to an ancient commit in a long-forgotten branch. + +It's hard to lose Git commits permanently, even after deleting branches. As long as you never run git-gc, your commits are preserved forever and can be restored at any time. + +The trouble is finding the appropriate hash. You could look at all the hash values in `.git/objects` and use trial and error to find the one you want. But there's a much easier way. + +Git records every hash of a commit it computes in `.git/logs`. The subdirectory `refs` contains the history of all activity on all branches, while the file `HEAD` shows every hash value it has ever taken. The latter can be used to find hashes of commits on branches that have been accidentally lopped off. + +Eventually, you may want to run git-gc to recover space. Be aware that doing so prevents you from recovering lost HEADs. + === Building On Git === In true UNIX fashion, Git's design allows it to be easily used as a low-level component of other programs. There are GUI interfaces, web interfaces, alternative command-line interfaces, and perhaps soon you will have a script or two of your own that calls Git. -- 2.11.4.GIT