DEV Community

Aliaksandr Valshtein
Aliaksandr Valshtein

Posted on

Git Extension to handle multiple repositories easily

The sad reality of software development is that not everyone uses git submodules, and dealing with multiple interconnected repositories can be tedious.

Naturally, a whole class of git extensions exists to solve this problem.

None of them suited me, so I created my own!

Generally, it's a good idea to use submodules or subtrees, but usually whether to use it or not is not up to you.

So I came up with a simple git extension to handle multiple repositories in bulk.

I present to you git-all

Let's assume that you have the following directory structure

my-awesome-repositories/
    my-awesome-repo-1/ # this is a git repository
    my-awesome-repo-2/ # that's another git repository
Enter fullscreen mode Exit fullscreen mode

Executing git all status inside my-awesome-repositories directory is the exact equivalent of executing the following bash commands:

cd my-awesome-repo-1
git status
cd ..

cd my-awesome-repo-2
git status
cd ..
Enter fullscreen mode Exit fullscreen mode

What can I do with it?

Whatever you want! Generally, almost everything you type after all will be passed to git unchanged.

The syntax is git all {basically any other git command}

Basically, you can do whatever git can do.

A couple of examples:

  • git all tag -a v1 -m "release" — this command tags all commits of every repository in the current subfolder with v1 tag and "release" tag message

  • git all push origin master — this one will push from all repositories in the current subfolder to branch master on the origin remote

What about cloning?

The only different thing about git all is cloning, but, instead of repository name you just need to provide a file where every line is an argument to regular git clone, and that's all (pun intended).

$ cat myrepo.list
--branch master https://github.com/stencila/test.git 
https://github.com/rtyley/small-test-repo.git
$ git all clone myrepo.list
Enter fullscreen mode Exit fullscreen mode

How it's different from similar extensions?

  • It's just a simple bash script, similar to one you could have written yourself
  • It's zero-configuration, you don't need to register directories, create workspaces and configuration files
  • It's written in bash, so you don't need to use Node.js or python
  • You don't need to learn how to use it, it's just your regular git commands

Top comments (1)

Collapse
 
wilddog64 profile image
chengkai

The similar extension is one come with git-extras, git-bulk that does just like this