Skip to content

Instantly share code, notes, and snippets.

@olix0r
Last active August 6, 2018 20:27
Show Gist options
  • Save olix0r/71310b3fef078cda7a3a to your computer and use it in GitHub Desktop.
Save olix0r/71310b3fef078cda7a3a to your computer and use it in GitHub Desktop.
git-unfuck
#!/bin/sh
set -e
if ! klist -t 2>/dev/null >&2 ; then
echo ":; :; kinit --keychain"
kinit --keychain
fi
branch=$(git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/\* \(.*\)/\1/')
if [ -z "$branch" ]; then
echo "Could not parse branch" >&2
exit 1
else
if [ $branch != "master" ]; then
echo ":; :; git co master"
git co master
fi
echo ":; :; git fetch origin master"
git fetch origin master
echo ":; :; git pull origin master"
git pull origin master
if [ $branch != "master" ]; then
echo ":; :; git co $branch"
git co $branch
echo ":; :; git merge --no-ff master"
git merge --no-ff master
fi
fi
#!/bin/sh
set -e
if ! klist -t 2>/dev/null >&2 ; then
echo ":; :; kinit --keychain"
kinit --keychain
fi
root=`git rev-parse --show-toplevel`
echo ":; :; git fetch"
git fetch
echo ":; :; git remote prune origin"
git remote prune origin
echo ":; :; git repack -a -d --depth=250 --window=250"
git repack -a -d --depth=250 --window=250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment