From: Jakub Narebski <jnareb@gmail.com>
To: "Avery Pennarun" <apenwarr@gmail.com>
Cc: "David Jeske" <jeske@google.com>, "Nicolas Pitre" <nico@cam.org>,
git@vger.kernel.org
Subject: Re: why is git destructive by default? (i suggest it not be!)
Date: Tue, 24 Jun 2008 00:54:38 -0700 (PDT) [thread overview]
Message-ID: <m3mylbl0xb.fsf@localhost.localdomain> (raw)
In-Reply-To: <32541b130806232220r292d691cn5bf5f9976126aa29@mail.gmail.com>
It looks like for some reason not all messages made it to git mailing
list, at least when using GMane to read git mailing list. Strange...
"Avery Pennarun" <apenwarr@gmail.com> writes:
> On 6/24/08, David Jeske <jeske@google.com> wrote:
>> I moved a branch around and then deleted it, and I don't see any
>> record in the reflog of where it was, or that it ever was.
Deleting branch (BTW. git prints warning when deleting branch can
result in [temporary] loss of [easy access to] some commits) deletes
its reflog[*1*], but you can still use HEAD reflog ("what was checked
out" reflog).
>> Am I missing something about how branches are used? I see some
>> language in "git tag" about how attempts are made to assure that
>> others can't move around semi-immutable tags during push, but I
>> don't see any such language about branches. What prevents someone
>> from accidentally deleting an old branch that nobody is watching,
>> but is important to the history and then not noticing as gc
>> silently deletes the old deltas?
BTW. branches _deletions_ are not by default transferred (even if
using globbing refspecs, which is not default); you have to use
"git remote prune <remote nick>" to remove remote-tracking branches
which track branches that got deleted on remote.
Besides nobody and nothing can fully protect you from your stupidity.
You can "accidentally" do 'rm -rf .git' for example :-/
>> I've had need to pull out versions several years old multiple times
>> in my career, so this is the kind of thing I'm thinking about.
The answer is: don't delete branches accidentally ;-).
Seriously, in any sane workflow you have several long lasting
branches, be it 'maint', 'master', 'next' or be it 'maintenance',
'stable'/'mainline'/'trunk', 'devel', into whose you merge in
[temporary, short lived] topic branches when topic is ready for
inclusion. And you NEVER delete such branches (git can't protect you
from deletion any more than Linux can protect you if you do "rm -rf ~").
Any commit for whose there is parentage line from one of those
long-lived "development" branches would be protected from pruning
during git-gc run.
> git branches are actually a very different concept from branches in,
> say, subversion.
>
> In subversion, a branch is normally created so that you can do
> parallel development, and then you merge whole batches of changes
> (with 'svn merge') from one branch into another. When you do this,
> you create a single new commit in the destination branch that contains
> *all* the changes. So if you want to look back in history to see who
> did which part of the change for what reason, you have to go back to
> the branch you merged *from*. Thus, it's very important in subversion
> that old branches never disappear.
>
> git's philosophy is different. Branches are really just "temporary
> tags".
I'd rather say thay branches (refs/heads branches) are "growth points"
of graph (diagram) of revisions (versions). (This graph is called DAG
in git documentation, because it is Directed Acyclic Graph).
But it is true that in git branches are just _pointers_ to the DAG
of commits. All data is kept in the content addressed object database
which is git repo storage, and parentage links are contained in commit
objects.
> A merge operation doesn't just copy data from one branch to
> another: it actually joins the two histories together, so you can then
> trace back through the exact history of the merged branches, commit by
> commit. "git log" will show each checkin to *either* branch
> individually, instead of just one big "merge" checkin.
Let me help explain that using some ASCII-art diagram. You need to
use fixed-width (non-proportional) font to view it correctly. Time
flows from the left to right.
Let's assume that we have the following state: some history on branch
'master':
object database refs information
/-------------------\ /---------------------\
.<---.<---.<---A <--- master <=== HEAD
For the commits the "<---" arrow means that commit on the right side
of arrow has commit on the left hand side of arrow as its parent
(saved in the multi-valued "parent" field in the commit object). For
the references "<---" arrow means that branch master points to given
commit, and "<===" means symbolic reference, i.e. that ref points to
given branch (you can think of it as symlink, and it was some time ago
implemented as such).
Now assume that we created new branch 'test', and we have comitted
some revisions being on it:
.<---.<---.<---A <--- master
\
\-B<---C <--- test <=== HEAD
Let's assume that we, or somebody else, did some work on 'master'
branch (to not confuse you with the "fast-formward" issue):
.<---.<---.<---A<---X<---Y <--- master
\
\--B<---C <--- test <=== HEAD
Now we have finished feature which we tried to develop in 'test', so
we merge changes back to 'master':
.<---.<---.<---A<---X<---Y<---M <--- master <=== HEAD
\ /
\--B<---C<-/ <--- test
Note how merge commit 'M' has two parents.
Now if we were to delete branch 'test' now:
.<---.<---.<---A<---X<---Y<---M <--- master [<=== HEAD]
\ /
\--B<---C<-/
it is only pointer that gets deleted (and reflog[*1*]). All commits
which were on this branch are 'reachable', so they never would get
deleted, even if [HEAD] reflog expires[*2*].
> The end result is that even if you delete the source branch after
> doing a merge, nothing is actually lost. Thus, there's no reason for
> git to try to make branches impossible to lose, as they are in svn.
> In the event that you really needed that branch pointer, it's in the
> reflog, as a few people have pointed out.
s/in the reflog/in the HEAD reflog/.
See above for explanation with pictures (or if you want some graphics,
take a look at presentations linked from GitLinks page and/or
GitDocumentation page on git wiki, http://git.or.cz/gitwiki/).
HTH
Footnotes:
==========
[*1*] There was an effort to create some sort of 'Attic' / 'trash can'
for deleted reflogs, but I guess it got stalled. There is techical
issue caused by the fact that reflogs are stored as files, and you can
have so caled file<->directory conflict, when you deleted branch
'foo', and created branch 'foo/bar'.
[*2*] You can always write "never" as time to expire, and it even
works now ;-)
--
Jakub Narebski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2008-06-24 7:55 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <jeske@willow=01l5V7waFEDjChmh>
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5V7wbFEDjCX7V>
2008-06-24 1:47 ` why is git destructive by default? (i suggest it not be!) David Jeske
2008-06-24 17:11 ` Boaz Harrosh
2008-06-24 17:19 ` Boaz Harrosh
2008-06-24 19:08 ` Jakub Narebski
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5zrLdFEDjCV3U>
2008-06-24 20:04 ` David Jeske
2008-06-24 20:04 ` David Jeske
2008-06-24 21:42 ` Brandon Casey
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l63P33FEDjCVQ0>
2008-06-24 22:13 ` David Jeske
2008-06-24 22:13 ` David Jeske
2008-06-24 22:54 ` Theodore Tso
2008-06-24 23:07 ` Junio C Hamano
2008-06-25 2:26 ` Theodore Tso
2008-06-25 8:58 ` Jakub Narebski
2008-06-25 9:14 ` Junio C Hamano
2008-06-26 15:13 ` Brandon Casey
2008-06-24 22:21 ` Steven Walter
2008-06-24 22:21 ` [PATCH] cmd_reset: don't trash uncommitted changes unless told to Steven Walter
2008-06-24 22:31 ` Junio C Hamano
2008-06-25 9:12 ` Boaz Harrosh
2008-06-25 9:23 ` Junio C Hamano
2008-06-25 9:59 ` Boaz Harrosh
2008-06-25 10:16 ` Johannes Schindelin
2008-06-25 10:24 ` Matthias Kestenholz
2008-06-25 10:46 ` Anton Gladkov
2008-06-25 12:33 ` Johannes Schindelin
2008-06-25 14:49 ` [PATCH] cmd_reset: don't trash uncommitted changes unless toldto Craig L. Ching
2008-06-25 15:18 ` Anton Gladkov
2008-06-25 10:41 ` [PATCH] cmd_reset: don't trash uncommitted changes unless told to Johannes Sixt
2008-06-25 12:38 ` Johannes Schindelin
2008-06-25 13:51 ` Theodore Tso
2008-06-25 17:22 ` Junio C Hamano
2008-06-25 19:50 ` Theodore Tso
2008-06-25 20:04 ` Avery Pennarun
2008-06-25 20:11 ` Junio C Hamano
2008-06-25 20:22 ` Avery Pennarun
2008-06-25 20:48 ` Junio C Hamano
2008-06-25 20:58 ` Avery Pennarun
2008-06-25 21:24 ` Re* " Junio C Hamano
2008-06-25 21:34 ` Junio C Hamano
2008-06-26 1:26 ` Junio C Hamano
2008-06-25 20:37 ` Steven Walter
2008-06-25 20:38 ` Theodore Tso
2008-06-25 20:50 ` Junio C Hamano
2008-06-25 21:05 ` Theodore Tso
2008-06-25 21:35 ` Junio C Hamano
2008-06-26 5:16 ` Junio C Hamano
[not found] ` <20080627193325.6117@nanako3.lavabit.com>
2008-06-27 22:11 ` Junio C Hamano
2008-06-28 0:06 ` しらいしななこ
2008-06-28 22:32 ` しらいしななこ
2008-06-29 8:56 ` Junio C Hamano
2008-06-25 22:44 ` Petr Baudis
2008-06-26 1:59 ` Johannes Schindelin
2008-06-25 20:09 ` Junio C Hamano
2008-06-26 11:55 ` Björn Steinbrink
2008-06-26 12:07 ` Johannes Schindelin
2008-06-26 12:35 ` Björn Steinbrink
2008-06-26 15:55 ` Avery Pennarun
2008-06-26 17:49 ` Johannes Schindelin
2008-06-26 12:01 ` Matthieu Moy
2008-06-26 12:09 ` Johannes Schindelin
2008-06-26 12:23 ` David Kastrup
2008-06-25 13:19 ` Ian Hilt
2008-06-26 5:31 ` Andreas Ericsson
2008-06-26 16:15 ` Jon Loeliger
2008-06-25 5:29 ` Johannes Gilger
2008-06-25 8:57 ` why is git destructive by default? (i suggest it not be!) Boaz Harrosh
2008-06-24 18:18 ` Brandon Casey
2008-06-24 1:47 ` David Jeske
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5V7wbFEDjCX7V@videotron.ca>
[not found] ` <willow-jeske-01l5cKsCFEDjC=91MX@videotron.ca>
2008-06-24 2:17 ` Nicolas Pitre
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5ciVtFEDjCaD9>
2008-06-24 3:18 ` David Jeske
2008-06-24 3:18 ` David Jeske
2008-06-24 8:14 ` Lea Wiemann
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5ciVtFEDjCaD9@videotron.ca>
[not found] ` <willow-jeske-01l5e9cgFEDjCh3F@videotron.ca>
2008-06-24 4:03 ` Nicolas Pitre
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5fAcTFEDjCWA4>
2008-06-24 4:40 ` David Jeske
2008-06-24 4:40 ` David Jeske
2008-06-24 5:24 ` Jan Krüger
[not found] ` <1978205964779154253@unknownmsgid>
2008-06-24 5:20 ` Avery Pennarun
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5gtQ7FEDjCWCC>
2008-06-24 6:35 ` David Jeske
2008-06-24 7:24 ` Jeff King
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5jmMuFEDjChvB>
2008-06-24 7:31 ` David Jeske
2008-06-24 8:16 ` Jeff King
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5kv6TFEDjCj8S>
2008-06-24 8:30 ` David Jeske
2008-06-24 8:30 ` David Jeske
2008-06-24 9:39 ` Jakub Narebski
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5kv6TFEDjCj8S@brm-avmta-1.central.sun.com>
[not found] ` <willow-jeske-01l5lTEoFEDjCVta@brm-avmta-1.central.sun.com>
2008-06-24 10:01 ` Fedor Sergeev
2008-06-24 10:24 ` David Jeske
2008-06-24 13:13 ` Theodore Tso
2008-06-24 7:31 ` David Jeske
2008-06-24 6:35 ` David Jeske
2008-06-24 7:54 ` Jakub Narebski [this message]
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5kQf4FEDjCXUa>
2008-06-24 8:08 ` David Jeske
2008-06-24 8:08 ` David Jeske
2008-06-24 11:22 ` Jakub Narebski
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5p7eVFEDjCZRD>
2008-06-24 11:29 ` David Jeske
2008-06-24 12:19 ` Rogan Dawes
2008-06-24 12:35 ` Johannes Gilger
2008-06-24 12:46 ` Rogan Dawes
2008-06-24 11:29 ` David Jeske
2008-06-24 12:21 ` Jakub Narebski
2008-06-24 12:13 ` Jakub Narebski
2008-06-24 4:59 Teemu Likonen
[not found] ` <e80d075a0806232201o3933d154he2b570986604c30a@mail.gmail.com>
2008-06-24 5:43 ` Teemu Likonen
-- strict thread matches above, loose matches on Subject: below --
2008-06-24 8:35 Björn Steinbrink
[not found] <willow-jeske-01l5oEsvFEDjCjRW>
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5oEswFEDjCZBN>
2008-06-24 10:42 ` David Jeske
2008-06-24 15:29 ` Brandon Casey
[not found] ` <willow-jeske-01l5PFjPFEDjCfzf-01l5uqS9FEDjCcuF>
2008-06-24 16:41 ` David Jeske
2008-06-24 16:41 ` David Jeske
2008-06-24 18:55 ` Brandon Casey
2008-06-25 12:20 ` Matthieu Moy
2008-06-25 17:56 ` Jing Xue
2008-06-24 10:42 ` David Jeske
2008-06-24 12:21 Olivier Galibert
2008-06-25 18:06 Dmitry Potapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3mylbl0xb.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=jeske@google.com \
--cc=nico@cam.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).