Delete a remote branch

When I execute branch -a:

$ git branch -a
* master
 remotes/origin/HEAD -> origin/master
 remotes/origin/hello
 remotes/origin/master

And then I delete the branch:

$ git branch -r -D origin/hello
Deleted remote branch origin/hello (was c0cbfd0).

Now I see:

$ git branch -a
* master
 remotes/origin/HEAD -> origin/master
 remotes/origin/master

The hi hole has been deleted. But when I get:

$ git fetch
From localhost:project
 * [new hello]      hello     -> origin/hello

$ git branch -a
* master
 remotes/origin/HEAD -> origin/master
 remotes/origin/hello
 remotes/origin/master

I'm so confused.
I think it was deleted, but it is still there.

+5
source share
4 answers

You need to remove it from the remote with the following command:

git push origin --delete hello

When git branch -rd origin/helloyou start, you delete only the local branch. The above code removes it from the original repo.

+6
source

To delete a remote branch , use

git push origin :remotebranch

Everything else works only in the local repository. In later versions of git, you can also

git push origin --delete remotebranch

--delete , .

:, push.

git push origin localbranch:remotebranch

localbranch "", .

+3

, git .

 git branch -r -D origin/hello

, .
> git push origin :hello, , .

, branch.hello.fetch: - origin/hello, .

+1
git push origin --delete somebranch

is a way to delete a remote branch. If you are still using the old version of Git, you may need to use the old syntax:

git push origin :somebranch

which translates as "do not click anything on any branch at a remote location indicated by origin." The command has the form "git push (which remote repo) (which local link) :( which remote link). The omission (which link) is interpreted as" do not put anything "(this remote link), effectively deleting it. The newer syntax is more intuitive is clear.

0
source

All Articles