Saturday, July 25, 2015

GIT checkout and reset --hard for all remote branches


#!/usr/bin/env bash
echo "present working directory is:";
pwd; 
echo ; 
echo "enter your GIT project dir, or .(dot) followed by [ENTER]:"
read directory
cd $directory;
echo "present working directory is:";
pwd; 
echo 'git fetch' 
git fetch
for branch in `git branch`; do
    echo "$branch";
    echo "git checkout $branch"
    git checkout $branch
    echo "git reset --hard origin/$branch"
    git reset --hard origin/$branch
    git log -1;
done
exit

No comments: