Saturday, June 27, 2015

GIT New Branch Creator


#!/usr/bin/env bash
echo "present working directory is:";
pwd; 
echo ; echo "enter your GIT project dir, followed by [ENTER]:"
read directory
cd $directory;
echo "present working directory is:";
pwd; 
echo 'git branch -vvv;';
git branch -vvv;
echo "this is the branch you are on [ENTER]";  
read a 
echo ; echo "enter branch you want to hard reset and use as new branch, followed by [ENTER]:"
read branch
git fetch; 
git checkout  $branch; 
git reset --hard origin/$branch;
echo ; echo "enter the new branch name, followed by [ENTER]:"
read newBranch
git checkout -b $newBranch $branch;
git push -u origin $newBranch;
echo 'git branch -vvv;';
git branch -vvv;
echo "this is the branch you are on [ENTER]";