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

Bug: Branch Deletion Doesn't Clean Up

From
KMKarl Moskowski <kmoskowski@me.com>
Date
Jan 7, 2016, 19:24 UTC
Message-ID
<4AC354E1-9E78-42A8-9828-BF1C084A6CBB@me.com>
Apologies if this is a known issue; I was unable to find anything similar in the archive.
The problem is, deleting a branch whose name contains slashes doesn’t delete the directories in .git/refs/heads/.
I’ve tried both git 2.5.4 and 2.6.4 on OS X 10.11 with HFS+ (case-insensitive, case-preserving). Here’s the sequence of commands:

% mkdir Foobar % cd Foobar/ % git init % git checkout -b master % touch file.txt % git add file.txt % git commit -m "add a file" % git checkout -b another/branch

At this point, there's file .git/refs/heads/another/branch

% git checkout master % git branch -d another/branch

At this point, there's an empty directory .git/refs/heads/another/. Only the “leaf” file noted above is deleted, not the directory above it.
% git checkout -b Another/branch
At this point, the file .git/refs/heads/another/branch is re-created. Note the case of its enclosing directory.

% git status On branch Another/branch nothing to commit, working directory clean

% git branch -l
  another/branch
  master
Note the difference in case between the last two commands' output. In addition, there's no asterisk next to another/branch indicating it's current.
Because the first branch deletion didn't also delete the enclosing directory tree below .git/refs/heads/, the new branch gets created beneath it. However, there's inconsistent info between the file system and the git database.
It seems like git branch -d ascend the hierarchy (up to .git/refs/heads/), deleting any empty directories.

---- Karl Moskowski <kmoskowski@me.com> <https://about.me/kolpanic>

Next: Jeff King
Message 1 of 7 in “Bug: Branch Deletion Doesn't Clean Up”
  1. Karl MoskowskiJan 7, 2016
  2. Jeff KingFeb 4, 2016
  3. Jeff KingFeb 4, 2016
  4. Mike HommeyFeb 4, 2016
  5. Jeff KingFeb 4, 2016
  6. Mike HommeyFeb 4, 2016
  7. Jeff KingFeb 4, 2016

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.