Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"branch ... not fully merged" immediately after fetch

Tags:

git

github

The following makes no sense to me

% git clone $REPO_URL --branch dev wd
% cd wd
% git fetch origin master:master
From github.com:ghuser/someproj
 * [new branch]      master     -> master
% git branch -d master
error: The branch 'master' is not fully merged.
If you are sure you want to delete it, run 'git branch -D master'.

Note that the above error message occurs on a git branch -d master command that happens immediately after the master branch has been fetched from the remote repo. Does it mean that origin is corrupted somehow? I can't figure out how this happened.

like image 548
kjo Avatar asked Mar 07 '13 18:03

kjo


People also ask

Why is a branch not fully merged?

There are times when you get an “not fully merged” error for a git branch, usually when trying to delete a local branch from your machine. It's a safe bet that something in your local branch has not actually made it to the remote repository and we should do some investigating.

How do I force delete a branch?

The -D flag, with a capital D (which is an alias for -- delete --force ), forcefully deletes the local branch, regradless of its merged status. But note that you should use this command should with caution, as there is no prompt asking you to confirm your actions.

How do I remove a remote git branch?

To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .


1 Answers

The warning

branch is not fully merged

comes when the branch you are trying to remove is not merged into another one. This warning saves you from removing a branch and its changes before you merge them, so you don't lose your changes.

In your case it looks like you didn't have the branch 'master' in your computer since you get the message

* [**new branch**]      master     -> master

So when you downloaded the branch master you where on dev and then you tried git branch -d master but since it was not merged from the point of view of dev you got the message

With gitk --all you can see the whole tree and there you will see how the branch master is not merged into another. Hence the message.

If you still want to remove it just use the -D command

like image 182
iberbeu Avatar answered Oct 16 '22 07:10

iberbeu