anatoly techtonik anatoly techtonik - 9 days ago 6
Git Question

error: The branch 'yourname' is not fully merged with removed remote

Can't remove local branch that was merged and removed from GitHub.

$ git branch -d startapp
warning: not deleting branch 'startapp' that is not yet merged to
'refs/remotes/origin/startapp', even though it is merged to HEAD.
error: The branch 'startapp' is not fully merged.
If you are sure you want to delete it, run 'git branch -D startapp'.

$ git branch
* master
startapp

$ git checkout startapp
Switched to branch 'startapp'
Your branch is ahead of 'origin/startapp' by 65 commits.
(use "git push" to publish your local commits)

$ git pull
Your configuration specifies to merge with the ref 'startapp'
from the remote, but no such ref was fetched.


The branch was removed after it was merged from GitHub. It is also fully merged in to master.

$ git log --graph --left-right --cherry-pick --oneline master...startapp
$
$ git log --graph --left-right --oneline master...startapp
$


Why the complain?

Answer

From man git-branch:

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

Your branch is not fully merged to the upstream branch that was set ( and now it cannot be so merged because that upstream branch has been deleted).

This is a reasonable safety check: you want to think twice about deleting a branch that has commits not pushed to its origin. If you happen to know that everything is hunky dory, then follow the advice in the diagnostic:

If you are sure you want to delete it, run 'git branch -D startapp'.