akaros/scripts/git/git-untrack
<<
>>
Prefs
   1#!/bin/bash
   2# Barret Rhoden (brho@cs.berkeley.edu)
   3# Copyright 2016 Google Inc
   4#
   5# Stops tracking a remote branch
   6
   7usage()
   8{
   9        echo "$0 <remote>/<branch>"
  10        exit -1
  11}
  12
  13if [ $# -ne 1 ]
  14then
  15        usage
  16fi
  17
  18REMOTE=`echo $1 | cut -f 1 -d '/'`
  19BRANCH=`echo $1 | cut -f 2- -d '/'`
  20
  21git remote | grep $REMOTE > /dev/null
  22if [ $? -ne 0 ]
  23then
  24        echo "Remote $REMOTE not tracked at all!"
  25        usage
  26fi
  27
  28if [ "x$BRANCH" == "x" ]
  29then
  30        echo "No branch!"
  31        usage
  32fi
  33
  34git branch -dr $REMOTE/$BRANCH
  35sed -i "/$REMOTE\/$BRANCH/d" .git/config
  36