首页 > 其他分享 >Git: delete all branches without upstream

Git: delete all branches without upstream

时间:2022-11-09 18:58:40浏览次数:38  
标签:Git branches without branch upstream delete

 

#!/usr/bin/env bash

# delete all branches without upstream
while read branch; do
    upstream=$(git rev-parse --abbrev-ref $branch@{upstream} 2>/dev/null)
    if [[ $? == 0 ]]; then
        # upstream exists
        echo $branch tracks $upstream
    else
        # no upstream --> delete
        git branch -d $branch
    fi
done < <(git for-each-ref --format='%(refname:short)' refs/heads)

 

标签:Git,branches,without,branch,upstream,delete
From: https://www.cnblogs.com/dissipate/p/16874799.html

相关文章

  • 使用用户 和 密码的形式访问git 私有仓库
    gitclonehttp[s]://username:password|PAT@actual-git-url-for-the-repo用户名、password或者PAT中不要包含@符号,如果有的话需要做url转义,比如@需要替换为%40,......
  • git warning: LF will be replaced by CRLF in package.json解决办法
    敲完代码后,如果修改了package.json文件,在终端用git进行同步时,gitadd.后会报如下错误:warning:LFwillbereplacedbyCRLFinpackage.json.Thefilewillhaveits......
  • Git_常用的Linux命令
    cd改变目录cd..回退到上一个目录,直接cd进入默认目录pwd显示当前所在的目录路径ls(ll)都是列出当前目录的所有文件,只不过ll列出的内容更为详细touch新建一个文件......
  • Git_工作原理
    Git本地三个工作区域:Workspace工作目录(平时放代码的地方)Index/Stage暂存区(文件。用于临时存放改动,保存即将提交到文件列表信息)Repository资源库(资源。安全存放数据......
  • Git_项目创建及克隆
    命令pull、fetch/clone、checkout、push、commit、add 创建本地仓库的两种方法:创建全新的仓库gitinit克隆远程仓库——Clonegitclo......
  • Git_版本控制
    目录版本控制聊聊Git历史git环境配置git基本理论git项目搭建---------------git文件操作使用码云 IDEA中集成git说明:git分支 版本控制–版本迭代版本控制......
  • 多人协作 GitHub 部分
    多人协作GitHub部分文章目录​​多人协作GitHub部分​​​​二、创建仓库​​​​三、增加合作者​​​​四、添加issue​​建议大家准备两个浏览器和两个GitHub账......
  • git push错误failed to push some refs to的解决
    问题说明当我们在github版本库中发现一个问题后,你在github上对它进行了在线的修改;或者你直接在github上的某个库中添加readme文件或者其他什么文件,但是没有对本地库进行同......
  • Github上优秀团队项目(阿里。腾讯,微软,谷歌,推特,微博,字节,苹果,小米,网易,奈飞等等),大厂技术
    亚马逊–​​https://github.com/aws​​Facebook–​​https://github.com/facebook​​腾讯–​​https://github.com/Tencent​​阿里巴巴集团–​​https://......
  • git的一些操作
    1、在工作区的代码gitcheckout a.txt  #丢弃某个文件,或者gitcheckout  .      #丢弃全部注:gitcheckout.丢弃全部,包括:新增的文件会被删除、删除的......