I'm a git beginner.
I tried making a branch while studying git, but I think I did something wrong.
So the repository was created as below. (Sorry, I don't remember the process well)
HEAD origin/HEAD origin/origin/release_251q
master origin/master origin/release_251q
So, I want to delete "origin/origin/release_251q"
How to delete it ??
I'm a git beginner.
I tried making a branch while studying git, but I think I did something wrong.
So the repository was created as below. (Sorry, I don't remember the process well)
HEAD origin/HEAD origin/origin/release_251q
master origin/master origin/release_251q
So, I want to delete "origin/origin/release_251q"
How to delete it ??
Share Improve this question edited Jan 19 at 12:22 dani-vta 6,8307 gold badges49 silver badges65 bronze badges asked Jan 19 at 11:10 kay.kimkay.kim 11 02 Answers
Reset to default 2Topic branches can be deleted with the command git branch
supplied with the -d
option and the branch name.
git branch -d <branch_name>
However, a branch can be deleted only if it's not currently checked out and if its commits are reachable from the current branch. In case the second condition is not satisfied, you can force the deletion by using the -D
option instead of -d
.
git branch -D <branch_name>
Instead, tracking branches can be deleted by supplying the -r
option along with -d
, the remote's name, and the tracking branch to delete.
git branch -d -r <remote>/<branch_name>
To assess whether origin/origin/release_251q
is a topic branch or a tracking branch, run git branch -vv
and check if it appears in the list on the left (as a topic branch) or on the right between square brackets (as a tracking branch). For example, here master
, develop
, and release/6.2.12
are topic branches, while origin/master
, origin/develop
, and origin/release/6.2.12
are their corresponding tracking branches.
git branch -vv
develop cf73514 [origin/develop] my commit message
master 2ebf2ef [origin/master] another commit message
* release/6.2.12 e8b026f [origin/release/6.2.12] a commit message
...
You didn't write which command produced the output you paste in your question, I will assume this is the output of git branch -a
, that origin/release_251q
is the local branch with the problematic name, and origin/origin/release_251q
is an indication of the remote branch.
To rule out any ambiguity, please run git for-each-ref
and paste the output of that command.
To delete the remote branch with the problematic name, run:
git push origin -d origin/release_251q
Locally, to give the correct name to your branch, run:
git branch -m origin/release_251q release_251q
If you want to create a remote branch with the name `release_251q, run:
git push origin release_251q