删除本地和远程分支
July 29, 2024 by
Terminal
# 删除本地分支
git branch -d localBranchName
# 删除远程分支
git push origin --delete remoteBranchName
# 同步分支列表
git fetch -p
删除本地分支
- 切换到其它分支
git branch -d <branch>
删除本地分支 (已合并到远程分支)git branch -D <branch>
强制删除本地分支 (未推送或合并)
删除远程分支
git push origin --delete <branch>
删除远程分支git push origin :<branch>
删除远程分支 (等同于上一条命令)- 以下报错表示分支已被删除或不存在
error: unable to push to unqualified destination: remoteBranchName The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'git@repository_name'