Skip to content

Instantly share code, notes, and snippets.

@timabell
Last active June 21, 2021 16:18
Show Gist options
  • Save timabell/1391205 to your computer and use it in GitHub Desktop.
Save timabell/1391205 to your computer and use it in GitHub Desktop.
deal with multiple git repositories
#!/bin/bash
# refs http://tim.theenchanter.com/2008/06/garbage-collect-every-git-repository-on.html
# This script hosted at https://gist.github.com/1391205
echo "Searching..."
find -L . -maxdepth 3 -type d -name .git | while read dir;
do
pushd "$dir" > /dev/null
cd ..
echo
echo '=============================='
pwd;
echo '------------------------------'
echo "many> git $@"
git "$@"
popd > /dev/null
done
echo "Done."
#!/bin/sh
# https://gist.github.com/timabell/1391205
# For when a PR has been merged on github.
# You should have the merged branch checked out.
# This will put you on master, get you up to date and delete the now merged branch
# get name of remote HEAD branch https://stackoverflow.com/questions/66232497/git-alias-which-works-for-main-or-master-or-other/67672350#67672350
main=`git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4`
br=`git symbolic-ref --short HEAD`
git checkout "$main" # assumes local tracking branch has same name as upstream HEAD
git fetch --all --prune
echo "Updating to latest $main ..."
git merge --ff-only origin/HEAD
git branch -d $br
#!/bin/bash
# https://gist.github.com/timabell/1391205
# see also https://github.com/Acader/withPS for powershell
echo "Git repl. Ctrl-c to quit."
while [ true ]
do
echo
read -p "git> " cmd
eval "git $cmd"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment