How to remove remote branch only from my local git? [duplicate]

不羁的心 提交于 2021-01-29 06:53:53

问题


I know the command git push -d <remote> <branch_name>

I want to delete remote branch only from my local git env. The command above removes remote branch from my local and remote github also.

However, if I had removed remote branch in github directly like this,

there is no branch named feature/search in remote anymore, the command fails.

So, how can I remove remote branch in my local without interacting remote github?


回答1:


Previously answered here.


You can use git branch -D or git branch -d for deleting a branch locally.

from the official doc

  -d
  --delete
  Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if 
  no upstream was set with --track or --set-upstream-to.

  -D
  Shortcut for --delete --force.

In your case, it should be,

  git branch -d feature/search


来源:https://stackoverflow.com/questions/63146613/how-to-remove-remote-branch-only-from-my-local-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!