git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: A couple branch questions

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2008, 03:43 UTC
Message-ID
<7vr6fgkxt2.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<ee77f5c20802131903i45b1629fpcb4a5c6e4f483052@mail.gmail.com>
"David Symonds" <dsymonds@gmail.com> writes:
Show 5 quoted lines
> If I have four branches, a, b1, b2 and c, and I've merged b2 into c
> (but planning to keep developing on b2), and just merged b1 into a
> (which I have checked out), then I probably only want to delete b1,
> not b2. The "current" branch is a useful notion because it
> significantly simplifies merging/rebasing operations.
Not just "simplifies", but it tends to make it much safer.

People often mistake that the safety of "branch -d" is to not lose the commit (i.e. not making it unreachable), but that is not the case. That safety already exists in HEAD reflogs.

The "branch -d" safety is about not losing the particular point. The information we really are trying to protect is "this branch points at _that commit_", which is just as important if not more.

And immediately after merging that branch into your current branch is where we can be fairly certain that you are truly done with the branch and that did not make a typo, if we hear you say "I do not need that branch anymore, delete it". "If it is merged in _some random branch_" does not give such an assurance and an inappropriate test for this purpose.

I should point out that the current protection based on HEAD predates the invention of the "branch --track". If we were designing the safety today, it would have taken the form of "if the branch to be removed is fully merged in the branch that it used to be tracking, or the current branch, then it is safe to remove it.".

Previous: David SymondsNext: Brian Downing
Message 5 of 15 in “A couple branch questions”
  1. Jay SoffianFeb 14, 2008
  2. David SymondsFeb 14, 2008
  3. Bill LearFeb 14, 2008
  4. David SymondsFeb 14, 2008
  5. Junio C HamanoFeb 14, 2008
  6. Keeping reflogs on branch deletionBrian Downing, Feb 14, 2008
  7. Nicolas PitreFeb 14, 2008
  8. Johannes SchindelinFeb 14, 2008
  9. Jeff KingFeb 14, 2008
  10. Nicolas PitreFeb 14, 2008
  11. Jeff KingFeb 14, 2008
  12. Nicolas PitreFeb 14, 2008
  13. Jeff KingFeb 14, 2008
  14. Wincent ColaiutaFeb 14, 2008
  15. Jakub NarebskiFeb 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.