home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] simple question about deleting a branch in git

  • Subject: Re: [OCLUG-Tech] simple question about deleting a branch in git
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Mon, 21 Sep 2015 06:48:22 -0400 (EDT)
On Mon, 21 Sep 2015, Richard Guy Briggs wrote:

> On 15/09/21, Robert P. J. Day wrote:
> >
> >   perusing o'reilly's "version control with git (2nd ed)", doing more
> > proofreading possibly in preparation for a 3rd edition, and ran across
> > this passage about deleting branches i hadn't noticed before:
> >
> > "Git won?t allow you to delete a branch that contains commits that are
> > not also present on the current branch. That is, Git prevents you from
> > accidentally removing development in commits that will be lost if the
> > branch were to be deleted."
> >
> >   hang on, that sounds contradictory. the first line claims that git
> > won't allow you to delete a branch that contains commits not on the
> > *current* branch, but the second line sounds more general in that git
> > doesn't want you to delete a branch where you might lose work, but as
> > long as the deleted branch commits are present on *some* branch (not
> > necessarily the current one), you should be fine.
> >
> >   can someone clarify this? is this as confusing as it seems to be to
> > me?
>
> My understanding is the -d option to delete a branch won't let you
> do so unless it is in another branch (don't remember which branch),
> but -D will force that delete regardless of the changes' existence
> in another branch.

  i read further into that section (can't believe i proofread this
once and just forgot the details), it reads:

"By stating that the bug/pr-3 branch is not an ancestor of your
current HEAD, Git is telling you that the line of development
represented by the bug/pr-3 branch does not contribute to the
development of the current branch, master.

"Git is not mandating that all branches be merged into the master
branch before they can be deleted. Remember, a branch is simply a name
or pointer to a commit that has actual content. Instead, Git is
keeping you from accidentally losing content from the branch to be
deleted that is not merged into your current branch.

"If the content from the deleted branch is already present on another
branch, checking that branch out and then requesting the branch
deletion from that context would work."

  so it seems that git really is requiring that, to do a *normal*
(that is, not forced) delete, the branch to be deleted must be
reachable from your *current* branch, not just any branch, even though
that certainly seems like overkill.

  ok, i'll accept that, unless someone has opinions to the contrary.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================