Z
Z
zlodiak2018-04-01 13:21:59
git
zlodiak, 2018-04-01 13:21:59

How to delete a merged branch?

I had 2 branches: master and second. I did
git checkout master && git merge second
. As a result, I got this picture:

[email protected] /var/www/html/misc/tag $ git hist --all
* 4679488 2018-04-01 | 7 (HEAD -> master) [zlodiak]
*   e41e917 2018-04-01 | 6 [zlodiak]
|\  
| * 91d2463 2018-04-01 | 5s (second) [zlodiak]
| * 3e391bf 2018-04-01 | 4s [zlodiak]
* | 8b04f4d 2018-04-01 | 5 [zlodiak]
* | ee26071 2018-04-01 | 4 [zlodiak]
|/  
* 3a0067f 2018-04-01 | 1 [zlodiak]
* d532d4a 2018-04-01 | 0 [zlodiak]

I would like to get rid of the branch: 91d2463, 3e391bf so that the history looks like one line.
To do this, I tried to delete the second branch like this:
git br -D second
As a result, I did not solve the problem, but got the following result:
[email protected] /var/www/html/misc/tag $ git hist --all
* 4679488 2018-04-01 | 7 (HEAD -> master) [zlodiak]
*   e41e917 2018-04-01 | 6 [zlodiak]
|\  
| * 91d2463 2018-04-01 | 5s [zlodiak]
| * 3e391bf 2018-04-01 | 4s [zlodiak]
* | 8b04f4d 2018-04-01 | 5 [zlodiak]
* | ee26071 2018-04-01 | 4 [zlodiak]
|/  
* 3a0067f 2018-04-01 | 1 [zlodiak]
* d532d4a 2018-04-01 | 0 [zlodiak]

As you can see, branch 91d2463, 3e391bf still exists. Please help me get rid of it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2018-04-01
@zlodiak

As you can see, branch 91d2463, 3e391bf still exists. Please help me get rid of it.

You can't get rid of it without rewriting the history of master. Deleting a branch is deleting the history line that ends with commit 91d2463. But this commit is already frozen in master, deleting the branch will not affect the view of master in any way.
If you want to rewrite master and get a linear history, you can do git rebase 3a0067f.

S
Stanislav Makarov, 2018-04-01
@Nipheris

1. You want bad things.
2. To do this, you need to rebase commits 91d2463, 3e391bf from 3a0067f to 8b04f4d.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question