Re: master^ is not a local branch -- huh?!?
- From
Michael Witten <mfwitten@gmail.com>
- Date
- Jan 30, 2010, 00:33 UTC
- Message-ID
- <b4087cc51001291633l68760880i340d12e865641077@mail.gmail.com>
- In-Reply-To
- <ron1-6C7BCB.14122429012010@news.gmane.org>
On Fri, Jan 29, 2010 at 4:12 PM, Ron Garret <ron1@flownet.com> wrote:
Show 19 quoted lines
> In article <7vmxzwh906.fsf@alter.siamese.dyndns.org>, > Junio C Hamano <gitster@pobox.com> wrote: > >> Sverre Rabbelier <srabbelier@gmail.com> writes: >> >> > On Fri, Jan 29, 2010 at 22:24, Ron Garret <ron1@flownet.com> wrote: >> >> Yes, I read that. But what I'm trying to do is not just *look* at the >> >> history, I want to restore my working tree to a previous version. The >> >> "Exploring History" section of the docs doesn't say how to do that. >> > >> > Do you want to restore your working tree only, or also throw away the >> > history? If the former, you could look at 'git revert',... >> >> I think he wanted to check paths out of a commit and the set of paths >> happened to be "everything". >> >> IOW, "checkout $commit ." > > Yes!!! That's it exactly!
However, that updates the index and doesn't delete files that didn't exist in $commit, and you said earlier that you don't want to update the index (though perhaps you didn't really know what you wanted there).
My idea:
Isn't the difference between 'checkout' and 'reset' almost essentially a matter of whether the branch reference (HEAD), index, and tree are modified? Couldn't these commands be merged into one command or make use of one command?
Rather than relying on flags like --hard, --soft, and --mixed, why not *also* provide flags for specifying at a finer granularity what is desired for the index, working tree, and HEAD.
Then:
git checkout $commit
does a lot of its work through something like:
git update --index --tree --detach $commitAlso:
git checkout $commit $f
translates:
git update --index --tree --keep-tracked-files $commit $fAlso:
git reset [--mixed] $commit
translates:
git update --index --head $commitAlso:
git reset --soft $commit
translates:
git update --head $commitAlso:
git reset --hard $commit
translates:
git update --index --tree --head $commitAnd so on.
In fact, with --no-* flags, you could modify 'reset' and 'checkout' commands from their defaults. So, to update all of the paths (including deleting tracked files not in $commit), but keep the index untouched, we have:
git checkout --no-update-index --no-update-keep-files $commit .
Of course, you might as well just use the hypothetical 'update' command directly:
git update --tree $commit .
Sincerely, Michael Witten