Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git branch -d gives warning

Tags:

git

Just want to get a better understanding of the warning message after I deleted a local branch

warning: deleting branch 'old_branch' that has been merged to 'refs/remotes/origin/old_branch', but not yet merged to HEAD.

like image 894
user1322228 Avatar asked Aug 27 '12 18:08

user1322228


3 Answers

This is just warning you that you have changes pushed to the branch on origin, but they are not merged into the currently checked out branch, so you are only deleting it locally.

It is warning you that you no longer have a local copy of that branch, but it exists in origin

If you want to delete the remote branch as well, use git push --delete origin old_branch

like image 153
cjhveal Avatar answered Nov 11 '22 04:11

cjhveal


Assuming you currently have master checked out, it means the changes made in old_branch aren't present in master. However, they are present in old_branch on origin.

like image 42
Karl Bielefeldt Avatar answered Nov 11 '22 03:11

Karl Bielefeldt


This means your local branch old_branch is up to date with remote branch old_branch on remote origin but it is not merged to the branch master which is considered to be the main branch in the repo.

It is just a precaution from git. It gives you a hint: maybe you did your job in the topic-branch and forget to merge it to the main branch?


update

Git warns you from losing your changes. For example if you do not have your old_branch on the master git then don't allow you to even delete branch that is unmerged to the master (well it allow, but with key -D which is force-delete option).

like image 10
Max Komarychev Avatar answered Nov 11 '22 04:11

Max Komarychev