-
Notifications
You must be signed in to change notification settings - Fork 4
Repository Sets
Working with multiple repos at once
As you have seen you can define a big amount of repositories with repo listers, but what can you do now with them? The easiest thing is to display them all or just a subset. Therefore you use the metagit list
command with or without a selector.
A selector is a expression that filters all your repos and just gives you the matching ones. The most selectors are just Regular Expressions (Python) that are matched against the statusline (See Repository for details). If the selector matches the repository is selected. Here two examples for use of simple selectors:
$ metagit list hub
+ (git:hub) [email protected]:stettberger/ethersex.git --> ~/github/ethersex
- (git:hub) [email protected]:stettberger/IR77.git --> ~/github/IR77
- (git:hub) [email protected]:stettberger/rs232-to-rs485.git --> ~/github/rs232-to-rs485
- (git:hub) [email protected]:stettberger/sup-mail.git --> ~/github/sup-mail
- (git:hub) [email protected]:stettberger/levitation.git --> ~/github/levitation
- (git:hub) [email protected]:stettberger/ethersexVortrag.git --> ~/github/ethersexVortrag
- (git:hub) [email protected]:stettberger/i3status.git --> ~/github/i3status
- (git:hub) [email protected]:stettberger/rpg-sheet.git --> ~/github/rpg-sheet
+ (git:hub) [email protected]:stettberger/metagit.git --> ~/github/metagit
$ metagit list hub.*meta
+ (git:hub) [email protected]:stettberger/metagit.git --> ~/github/metagit
But there are some special purpose selectors
-
+
,b
,-
,N
: these will just match the state of a repository according to the statusline -
.
will match the repository you are within (closest match)
Generally you can run every scm command with a set of repos choosen by a selector. The command therefore is metagit foreach
. Here a example for its usage:
$ m foreach hub.*meta log --oneline
cd '/home/stettberger/github/metagit'; git log '--oneline'
69bb6e9 implement '.' selector correctly
bfa6c18 fix indentation of clone
d49c6f3 remove debug print
....
The command after the selector (here “hub.*meta”) will be prefixed by the scm binary and executed in every selected repo. But there are some handy shortcuts:
- alias commit <selector> = foreach <selector> commit
- alias fetch <selector> = foreach <selector> fetch
- alias pull <selector> = foreach <selector> pull
- alias push <selector> = foreach <selector> push
- alias status <selector> = foreach <selector> status
$ metagit foreach foobar commit -a -m "autocommit"
is the same as
$ metagit commit foobar -a -m "autocommit"