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: Alex Pilon <alp [ at ] alexpilon [ dot ] ca>
  • Date: Mon, 21 Sep 2015 11:35:53 -0400
> > >   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),

The upstream is the branch you are looking for.

git-branch(1):

    -d, --delete
		Delete a branch. The branch must be fully merged in its upstream
		branch, or in HEAD if no upstream was set with --track or
		--set-upstream.

>   i read further into that section (can't believe i proofread this
> once and just forgot the details), it reads:
> […]
> "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.

That sounds mighty fishy were I to have many other intertwined branches
not related to the one I'm currently on.

> "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 then, what about this scenario?

   ______ A
  /  ____\________ B
 /  /
------------------------ master
  \_______________ HEAD -> C

Busy at work now. Will get back to this later. Would `git branch -d A`
work here, despite B not being its upstream?

>   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.

It is.

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

Run any experiments to try and break that statement?

Regards,

Alex Pilon