accidentally typed in the console wrong and now I can not delete the wrongly named branch:

git branch develop * master origin/admin-news 

how do i delete the last thread (origin / admin-news)

  • one
    two options - take the name of the branch in a quotation mark or add a bekslesh before the slash ( origin\/admin-news ) - KoVadim
  • @KoVadim, it works fine for me without it. see my answer. - aleksandr barakin
  • one
    yes i have seen Checked under Linux everything is well removed. I decided that, looking at origin/admin-news , git will decide that this is a remote branch, and it is local. But git was surprised once again. But in general, it is strange, usually in the name of a branch you cannot use characters that cannot be used in the file name. Looked deeper. git created a folder in the .git/refs/heads/ directory ... original. - KoVadim

1 answer 1

the same branch command, but with the -d option

create:

 $ git branch origin/admin-news $ git branch * master origin/admin-news 

and delete:

 $ git branch -d origin/admin-news Deleted branch origin/admin-news (was 1ba85e8). $ git branch * master 

if in response to the git branch -d ... command git branch -d ... you will receive a message of the form:

error: The branch 'origin / admin-news' is not fully merged.
'Git branch -D origin / admin-news'.

and you are sure that you do not need unique commits in the deleted branch, then replace, as suggested in the message, the -d option with -D :

 $ git branch -D origin/admin-news Deleted branch origin/admin-news (was a6f907d). 
  • there should be an option -D big, for a small one swears: - akalend
  • @akalend, in man, there is a reservation about the difference between -d and -D , but for the sake of brevity I decided not to paint so much. I shall add. - aleksandr barakin
  • thanks for the addition - akalend