如何使用git删除本地和远程分支

时间:2021-05-06 16:23:59

So right now these are the branches I have:

所以现在这些是我的分支:

WalnutiQ> git branch -a
* develop
  feature-model_in_javascript
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature-model_in_javascript
  remotes/origin/master

My goal is to delete the branch feature-model_in_javascript so I tried:

我的目标是删除分支功能-mode_in_javascript,所以我尝试了:

WalnutiQ> git branch -d feature-model_in_javascript
Deleted branch feature-model_in_javascript (was 4604f04).

So now when I check my branchs I get:

所以现在当我检查我的分支时,我得到:

WalnutiQ> git branch -a 
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature-model_in_javascript # <== HOW DO I DELETE THIS????
  remotes/origin/master

How do I delete that remote branch? I manually deleted it by clicking the delete button on https://github.com/WalnutiQ/WalnutiQ/branches

如何删除该远程分支?我通过单击https://github.com/WalnutiQ/WalnutiQ/branches上的删除按钮手动删除它

3 个解决方案

#1


6  

If you have already manually deleted the branch on the upstream server, then use

如果您已经手动删除了上游服务器上的分支,那么请使用

git fetch -p

to "prune" your remote tracking branches. Any branches under remotes/origin that no longer exist on the server will be deleted from your local repository.

“修剪”你的远程跟踪分支机构。服务器上不再存在的远程/来源下的任何分支都将从本地存储库中删除。

#2


1  

Just use below to delete the remote branch:

只需使用以下删除远程分支:

git push origin :<branch>

remove remote tags is the same.

删除远程标签是一样的。

You can find details here: http://git-scm.com/book/en/Git-Branching-Remote-Branches

您可以在此处找到详细信息:http://git-scm.com/book/en/Git-Branching-Remote-Branches

#3


1  

A slightly more modern syntax for deleting remote branches (perhaps easier to remember) is:

删除远程分支(可能更容易记住)的稍微更现代的语法是:

git push origin --delete <branchName>

git push origin --delete

#1


6  

If you have already manually deleted the branch on the upstream server, then use

如果您已经手动删除了上游服务器上的分支,那么请使用

git fetch -p

to "prune" your remote tracking branches. Any branches under remotes/origin that no longer exist on the server will be deleted from your local repository.

“修剪”你的远程跟踪分支机构。服务器上不再存在的远程/来源下的任何分支都将从本地存储库中删除。

#2


1  

Just use below to delete the remote branch:

只需使用以下删除远程分支:

git push origin :<branch>

remove remote tags is the same.

删除远程标签是一样的。

You can find details here: http://git-scm.com/book/en/Git-Branching-Remote-Branches

您可以在此处找到详细信息:http://git-scm.com/book/en/Git-Branching-Remote-Branches

#3


1  

A slightly more modern syntax for deleting remote branches (perhaps easier to remember) is:

删除远程分支(可能更容易记住)的稍微更现代的语法是:

git push origin --delete <branchName>

git push origin --delete