Git-pull use current directory by default, that means you have to change into the repository directory first before you git-pull. It’s annoying, especially when you’ve got lots of Git repositories to pull at once. I haven’t found any solutions with Git’s internal functions. So, I wrote an simple bash function to solve this. Just put the following into the bash profile file.
function gg() {
if [ $# -gt 0 ]; then
for i in $(echo $*); do
if [ -d ${i} ]; then
( cd ${i} && git pull )
else
echo "No such directory: \"${i}\", skipping ..."
fi
done
else
echo "usage: gg <git repo dir>"
fi
}
The parameters can be either relative directories or absolute directories, wildcard is supported.
If there’s any better ways, such as Git’s internal methods, please let me know. Thanks.