cfg/bin/git-ps
Knut Ahlers 53bc6d62bd
Fetch tags on git ps
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-01-07 15:17:19 +01:00

32 lines
811 B
Bash
Executable File

#!/bin/bash
set -o pipefail
set -e
source "${HOME}/bin/script_framework.sh"
step "Loading required keys to pull"
git loadkey
step "Fetching data from remote..."
for remote in $(git remote -v | awk '{print $1}' | sort | uniq); do
step "+++ Remote: '${remote}'"
git fetch -p ${remote} --tags
done
step "Rebasing branch / updating submodules..."
git pull --rebase && git submodule update --init --recursive
step "Cleaning local branches..."
for branch in $(git branch --merged | grep -v '^*'); do
# Do not delete master as the main branch
if ( test "${branch}" != "master" ); then
git branch -d ${branch}
fi
done
step "Removing local branches where remote branch is gone..."
if ( git branch -vv | grep -q ': gone]' ); then
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
fi