Can I make git smarter when I find out if deleting a branch is good?

git branch -d almost always mistaken if there is code in the branch that I did not merge. Very often, I will have a forked foo from the master , the process is executed, and then merged with it into master , but then git branch -d says "Branch" foo is not completely merged "until I merge the master back into foo (sometimes it’s a pain )

+4
source share
4 answers

Unable to combine something in foo to remove foo .

As I understand it, the criterion is that foo is combined into HEAD , so perhaps you should make sure that master is your current one when you try to remove foo .

+4
source

in this case it looks like I squeezed foo commits

This will correspond to the warning “not fully merged” (branch with commits not available from any other head)

You can perform two checks:

1 / An interesting question is Git and The branch 'x' is not fully merged "Error ":

 git log --graph --left-right --cherry-pick --oneline master...foo 

2 / See " Using Git, show all commits that are in the same branch, but not the other (s) "

 git branch --contains branch-to-delete 

Multiple branches must be returned

+1
source

Do

 git rebase master foo 

after you leaked everything. Then a git branch -d foo should succeed

0
source
 #!/bin/sh # Get rid of all the branches I don't care about. for b in $(git branch) ; do git rebase master ${b} if test $? -ne 0; then git rebase --abort ; fi git checkout -f master done for b in $(git branch) ; do git branch -d ${b} ; done 
-5
source

Source: https://habr.com/ru/post/1339730/


All Articles