git如何删除远端分支

转自:http://elephantliu.blog.51cto.com/1107116/636967

曾经纠结于在github.com上开了太多分支导致分支过于混乱。一直在寻找删除远端分支的方法,可是网上搜到的方法都不好用。

无意间犯的一个错误导致github.com的项目上的一个分支被删除,才发现删除github.com分支的方法。希望能够为大家提供帮助。

思路:

新建一个空的版本库,直接把空的版本库push到github.com的某个分支上。这个分支就会被自动删除。

代码:

  1. remote_repo="https://github.com/lexdene/Dlut-Game-Platform.git" #这是我想删除分支的仓库地址
  2. remote_branch="libapi" #这是我想删除的远端仓库分支的名字
  3. mkdir /tmp/git-empty
  4. cd /tmp/git-empty
  5. git init
  6. git push $remote_repo :$remote_branch #有个冒号不能省略

全文完。

# 更新

git branch -d -r $remote_branch

git push remote_name --delete branch_name

本文出自 “elephant_liu” 博客,请务必保留此出处http://elephantliu.blog.51cto.com/1107116/636967

时间: 2024-08-04 08:15:27

git如何删除远端分支的相关文章

git删除远端分支

之前推送本地的代码到远端的时候,远端的分支名字写错了,导致远端产生了一个新的分支 之前用的git push -f origin Test:mater $ git push origin :materUsername for 'https://github.com': chuckluPassword for 'https://[email protected]':To https://github.com/chucklu/WCFTest.git - [deleted] mater git push

git如何删除远端不存在的本地分支?

问题:远端分支删除后,如何删除之前拉取的本地分支? 答案: git fetch -p git remote show origin 可以查看remote地址,远程分支,还有本地分支与之相对应关系等信息.使用git remote prune origin删除所有远端已经删除本地仍然存在的分支   参考: https://blog.csdn.net/LJFPHP/article/details/81741931 https://blog.csdn.net/qq_16885135/article/de

git批量删除本地分支及远程分支

1.批量删除本地分支 git branch |grep 'branchName' |xargs git branch -D git branch   查看本地分支 | grep 'branchName'  匹配分支名 | xargs git branch -D 将匹配到的分支名一个一个传递给git branch -D git branch -D branchName  删除本地分支 2.批量删除远程分支 git branch -r| grep 'branchName' | sed 's/orig

Git 如何删除本地分支和远程分支

切换到master分支 git checkout master 查看已有的本地及远程分支 git branch -a 删除远程分支 git push origin --delete dev 删除后,再次查看分支情况 git branch -a 删除本地分支 git branch -d dev 远程分支和本地分支删除完毕 原文地址:https://www.cnblogs.com/caozhengze/p/11268293.html

git拉取远程分支并创建本地分支

本地分支推送至远程 git checkout local_branch git push origin local_branch:remote_branch 一.查看远程分支 使用如下Git命令查看所有远程分支: git branch -r 列出本地分支: git branch 删除本地分支: git branch -D BranchName 其中-D也可以是--delete,如: git branch --delete BranchName  删除本地的远程分支: git branch -r

git 查看远程分支、本地分支、删除本地分支

1 查看远程分支 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master 2 查看本地分支 1 2 3 4 5 $ git branch *

git 删除本地分支和远程分支、本地代码回滚和远程代码库回滚

[git 删除本地分支] git branch -D br [git 删除远程分支] git push origin :br  (origin 后面有空格) git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id [本地代码库回滚]: git reset --hard commit-id :回滚到commit-id,讲commit-id之后提交的commit都去除 git reset --hard HEAD~3:将最近3次的提交回滚 [远程代码库回滚]: 这个是重点要说的内容

git 删除远程分支 branch

git 删除远程分支 : git push origin :远程分支 例如删除远程分支 osc(楼主的origin是 osc): [email protected] MINGW64 ~/workspace/HelloWorld/src/selenium (master)$ git push osc :oscTo [email protected]:wuzhiyi51/selenium_learn.git - [deleted] osc git 创建分支(branch) git branch te

git 删除远程分支

1.可以使用这种语法删除远程分支 git push origin --delete <branchName> 删除tag这么用: git push origin --delete tag <tagName> 2. 删不掉可以使用这种语法,推送一个空分支到远程分支,其实就相当于删除远程分支 git push origin :<branchName> 这是删除tag的方法,推送一个空tag到远程tag git tag -d <tagName> git push