Re: About detached heads
- From
Nicolas Pitre <nico@cam.org>
- Date
- Mar 15, 2008, 00:38 UTC
- Message-ID
- <alpine.LFD.1.00.0803142025080.2947@xanadu.home>
- In-Reply-To
- <93c3eada0803141643r2f2c4c56l9e59f2ee7b67a8ca@mail.gmail.com>
On Sat, 15 Mar 2008, Geoff Russell wrote:
Show 7 quoted lines
> The context where I want to use this is for users who update files, > can understand > "take me back to the state I was in at 4pm yesterday before I mucked up > my data" but who don't want to know about merging, branching, topics, etc, etc, > But of course having taken them back to the 4pm commit, they then realise that > they really need the 6pm commit or perhaps the 3pm commit. So anything which > just throws away commits would be risky.
The reflog can help you there as well. You can simply do:
git reset --hard HEAD@{yesterday.at.4pm}and it'll magically bring you back to the state you were yesterday at 4pm. You need the 6pm state instead? No problem: just ask for yesterday.at.6pm then.
And before doing the 'reset --hard', you might want to do a simple 'checkout' beforehand so you can be sure it actually corresponds to what you want:
git checkout HEAD@{yesterday.at.4pm}
[compile, test, whatever]
git checkout HEAD@{yesterday.at.6pm}
[compile, test, whatever]and when OK with it, then:
# return to your master branch (or any other branch)
git checkout master
# then reset it to the desired state
git reset --hard HEAD@{yesterday.at.6pm}Nicolas