I have two remote branches with similar names. Will this command delete the right one?

57 views Asked by At

I have two remote branches:

  • origin/dev
  • origin/origin/dev

I want to delete origin/origin/dev.

Will the following command do what I want?

git push origin --delete origin/dev
1

There are 1 answers

1
jub0bs On BEST ANSWER

You would do well to pick better branch names; you would avoid a few headaches like this one :)

As I understand it, you have two branches living in the remote repo called origin:

  • dev
  • origin/dev

A quick test in a toy repo indicates that, under the assumption that origin/HEAD doesn't point to the remote branch called origin/dev, the command

git push origin --delete origin/dev

will indeed do what you want. To be clear, this command will

  • delete the branch called origin/dev that lives in the origin remote repo, and which is associated with your (local) remote-tracking branch origin/origin/dev.
  • leave intact the branch called dev that lives in the origin remote repo, and which is associated with your (local) remote-tracking branch origin/dev.