Skip to content

Instantly share code, notes, and snippets.

@saltedcoffii
Last active November 21, 2022 17:10
Show Gist options
  • Save saltedcoffii/752a548737d23d98b44c2dab754e4301 to your computer and use it in GitHub Desktop.
Save saltedcoffii/752a548737d23d98b44c2dab754e4301 to your computer and use it in GitHub Desktop.
update-git-repos.sh: update all git repositories in the current directory
#!/bin/bash
# update-git-repos.sh: update all git repositories in the current directory
# Copyright (C) 2022 Cassandra Watergate
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
for i in */; do
pushd ${i};
git fetch origin;
git pull origin $(git branch --show-current);
git reflog expire --expire=0;
git prune;
git prune-packed;
git gc --prune=all;
popd;
done
@saltedcoffii
Copy link
Author

I'm a software packager, and it's nice to be able to look at the way linux distros package files. I have a huge directory of package build scripts from archlinux, gentoo, void, alpine, and adélie linux and updating them all one at a time, or dealing with the huge amount of space that a fully deep .git directory takes up is really annoying. This script solved all my problems and I'm putting it here in hopes that someone else will find it useful too. Let me know if you use it in the comments below!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment