Sat. Feb 24th, 2024

You may or may not find this useful. I work with a my GIT repositories all at the same level. I like to keep them in sync. However going to each repository and repeating the commands is a pain. So I created the following shell script to make my life easier:

echo "Issuing command: $@"
for d in ./*/
    (cd "$d" && "$@" )

To use this, you just need to enter “mdexec pwd” to execute the “pwd” command in each subdirectory. The catch on this you will want/need to run this on each of the subdirectories in your current working directory.

Extending to Multi-Directory GIT

So we now have our “mdexec” command. Our next step is to create “mgit”

mdexec git $@

Now all you need to do is “mgit pull” or any standard git command to execute. GIT will be substituted into the command and run in each sub-directory.

By Jeffery Miller

I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.