无法删除已合并并从 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.
Run Code Online (Sandbox Code Playgroud)
该分支在从 GitHub 合并后被删除。它也完全合并到母版中。
$ git log --graph --left-right --cherry-pick --oneline master...startapp
$
$ git log --graph --left-right --oneline master...startapp
$
Run Code Online (Sandbox Code Playgroud)
为什么抱怨?
来自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.
Run Code Online (Sandbox Code Playgroud)
您的分支未完全合并到设置的上游分支(现在无法合并,因为上游分支已被删除)。
这是一个合理的安全检查:在删除提交未推送到其源的分支时,您要三思而后行。如果您碰巧知道一切都是笨蛋,那么请遵循诊断中的建议:
If you are sure you want to delete it, run 'git branch -D startapp'.
Run Code Online (Sandbox Code Playgroud)