Re: why is git destructive by default? (i suggest it not be!)
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jun 24, 2008, 12:13 UTC
- Message-ID
- <200806241413.24111.jnareb@gmail.com>
- In-Reply-To
- <200806241322.14224.jnareb@gmail.com>
Jakub Narebski wrote:
> David Jeske wrote:
Show 10 quoted lines
> > Now, five years down the road, [...] someone does: > > > > $ git-branch -f customer_A_branch ZZZ > > If they are using '-f', i.e. force, they should know and be sure what > they are doing; it is not much different from 'rm -f *'. > > If reflog for 'customer_A_branch' expired it would be hard to go back > to old 'customer_A_branch', and impossible after garbage collector > pruned history.
Actually it is not true. In the case of "git branch -f <branch>", which is the case which wouldn't be covered by protecting reflogs when deleting branches (saving them to some kind of "attic") git _saves_ old branch pointer to reflog, so "git log -g <branch>" would work as expected.
The reflog entry looks like the following:
0c52414d... 80b4c7e5.. A U Thor <author@example.com> 1214306246 +0200 \ branch: Reset from ZZZ
(where of course there are full SHA-1 of commits, instead of shortened ones, and everything is in single line, without line continuation.)
Show 5 quoted lines
> What you _should do_, if you want to preserve old 'customer_A_branch' > pointer is to *tag* it, e.g. something like 'Attic/customer_A_branch'; > if you use annotated tags you can even state why do you want to keep > old work, and why old work wasn't merged into long-lived branch, and > why the work was abandoned.
This of course is still valid.
-- Jakub Narebski Poland