1

From the man page for git branch:

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.

$ git branch -d skin
warning: deleting branch 'skin' that has been merged to
     'refs/remotes/origin/skin', but not yet merged to HEAD.
Deleted branch skin (was 1f97b5b).

$ git remote -v
origin  git@github.com:me/Banana.git (fetch)
origin  git@github.com:me/Banana.git (push)
upstream    git@github.com:others/Banana.git (fetch)
upstream    git@github.com:others/Banana.git (push)

The skin branch was actually removed (locally) but I was trying to understand what the warning message means. Note the skin branch was still available at origin and upstream, as expected.

moey
  • 9,619
  • 20
  • 64
  • 109
  • Maybe you haven't merged it into the current branch, locally? – Ry- Jul 28 '13 at 00:12
  • I just checked out the `skin` branch from the origin for preview. I didn't mean to work on it locally. After that, I thought let's delete it rather than it sitting there doing nothing; thus, I came across this warning. – moey Jul 28 '13 at 00:18
  • So it's not merged, and that's fine. It's just a warning, you can safely ignore it if it doesn't apply. – Ry- Jul 28 '13 at 00:18
  • `Deleted branch skin (was 1f97b5b)` -- what does the SHA-1 inside the parenthesis refer to? An older commit? – moey Jul 28 '13 at 02:58
  • It’s the commit `skin` pointed to. You could see what it is with `git show 1f97b5b` (assuming `git gc` hasn’t been run). – Ry- Jul 28 '13 at 04:22
  • @minitech: even with a `git gc` the commit will still exist, as the complaint was just a warning. `remotes/origin/skin` contains (in the `git branch --contains` sense) `1f97b5b` (I'm assuming the remotes head still exists, of course). – torek Jul 28 '13 at 05:31

1 Answers1

0

The warning means just what it says: the branch name you asked git to delete is not an ancestor of HEAD. Whatever branch you were on (e.g., master), skin named a commit that was not "part of" that branch. But, the name skin was a tracking branch name, and it named a commit that was "part of" the origin tracking branch, so git removed the branch label.

The branch label used to point to commit 1f97b5b. It's likely that origin/skin also points (or pointed) to 1f97b5b, i.e., the commit tree looked something like this:

A --- B --- C       <-- HEAD, master, origin/master
        \
          D --- E   <-- skin, origin/skin

where the SHA-1 of commit E is 1f97b5b. But it's possible that skin was a commit or more behind origin/skin, so that 1f97b5b is the ID of commit D, or B, or even A. The important thing is that starting from origin/skin it's possible to work backwards along the commit tree and find commit 1f97b5b, therefore git figures that it is "safe" to delete a label pointing to commit 1f97b5b.

torek
  • 330,127
  • 43
  • 437
  • 552
  • I assume a "tracking branch" is the term for a branch that has a remote i.e. not a pure local branch? – moey Aug 06 '13 at 12:21
  • 1
    Right, local branch L is "tracking" remote branch R (names need not match) if `git config branch.L.remote` is set to a remote name (like origin) and `git config branch.L.merge` has a ref name. See also http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch – torek Aug 06 '13 at 20:55
  • I didn't know L and R do not need to have the same name. And, thanks (+1) for the link. – moey Aug 08 '13 at 09:40