Command line utility to work with multiple git repositories at once
Currently intended for personal use only, but quite functional
Tested on: Arch Linux, with g++ 4.7.2 and g++ 4.8.1
- Clone this repo
git clone https://github.com/SuperV1234/git-ws
- Pull all submodules recursively
cd git-ws
./init-repository.sh
- Build all submodules +
git-ws
./build-repository-git-ws.sh
- You may have to append
/usr/local/lib
to the$PATH
or$LD_LIBRARY_PATH
environment variables to allow git-ws to find the required libraries - if that doesn't work, try:
sudo ldconfig /usr/local/lib
- Use
git-ws
!
Using git-ws
in a directory calls git commands in all subdirectiories which are git repositories.
Auto generated help
<? || help> (OPTARG Command name) [-v || --verbose]
>>Show help for all commands or a single command.
Optional arguments:
* (OPTARG Command name)
--Command name
--Name of the command to get help for.
--Leave blank to get general help.
Flags:
* [-v || --verbose]
--Verbose general help?
<push> [-f || --force] [-a || --all]
>>Pushes every git repo.
Flags:
* [-f || --force]
--Forced push?
* [-a || --all]
--Run the command in all repos (even non-ahead ones), for all branches.
<pull> [-s || --stash] [-f || --force-checkout] [-c || --changed-only]
>>Pulls every git repo.
Flags:
* [-s || --stash]
--Stash all changes before pulling?
* [-f || --force-checkout]
--Run a force checkout before pulling?
* [-c || --changed-only]
--Run the command only in folders where repos have changes?
<sub || submodule> (ARG Action) [-c || --changed-only]
>>Work with git submodules in every repo.
Required arguments:
* (ARG Action)
--Action
--Action to run for every submodule. Can be 'push', 'pull' or 'au'.
--'push' commits all changes in the repo and pushes them to the remote. Do not run this unless all non-submodule changes have been taken care of!
'pull' recursively pulls the latest submodules from the remote.
'au' calls 'pull' then 'push' in succession.
Flags:
* [-c || --changed-only]
--Run the command only in folders where repos have changes?
<st || status> [-a || --showall]
>>Prints the status of all repos.
Flags:
* [-a || --showall]
--Print empty messages?
<gitg> [-c || --changed-only]
>>Open the gitg gui application in every repo folder.
Flags:
* [-c || --changed-only]
--Open gitg only in folders where repos have changes?
<do> (ARG Command to run) [-c || --changed-only] [-a || --ahead-only]
>>Runs a shell command in every repo folder.
Required arguments:
* (ARG Command to run)
--Command to run
--This is the command that will be called in every repo folder.
--Consider wrapping a more complex command with quotes.
Flags:
* [-c || --changed-only]
--Run the command only in folders where repos have changes?
* [-a || --ahead-only]
--Run the command only in folders where repos are ahead of the remote?
<query>
>>Queries the status of all the repos, returning whether they are changed or ahead.
git-ws ?
: displays auto-generated help for all commandsgit-ws ? (command name)
: displays auto-generated help for a commandgit-ws query
: displays all repos detected by git-wsgit-ws push
: push staged changesgit-ws push -f
: force push staged changesgit-ws push -a
: push staged changes, only in repos ahead from remotegit-ws pull
: pull latest versiongit-ws pull -s
: pull latest version, stashing all changes before pullinggit-ws status
orgit-ws st
: displays short git status, ignoring dirty submodulesgit-ws submodule push
orgit-ws sub push
: commits all staged changes and pushes (intended to be used only after non-submodule changes have been pushed)git-ws sub pull
: stashes all submodule local changes, pulls latest submodules recursivelygit-ws sub au
: equivalent ofgit-ws submodule pull
followed bygit-ws submodule push
and bygit submodule update
git-ws do 'command here'
: creates a subshell in every git repo folder, and executes a bash command in itgit-ws do -c 'command here'
: creates a subshell in every git repo folder with changes, and executes a bash command in itgit-ws do -a 'command here'
: creates a subshell in every ahead git repo folder, and executes a bash command in it
Real-life situation: I'm working on Open Hexagon and related libraries.
I create a OHWorkspace
folder, where I clone all the required git repos.
mkdir OHWorkspace; cd OHWorkspace
git clone http://.../SSVUtils
git clone http://.../SSVUtilsJson
git clone http://.../SSVStart
git clone http://.../<etc>
git clone http://.../SSVOpenHexagon
Now my directory tree looks like this:
OHWorkspace/
...
SSVUtils/
.git/
...
SSVUtilsJson/
.git/
...
SSVStart/
.git/
...
SSVOpenHexagon/
.git/
...
I work on all the repos simultaneously. I constantly need to check what repos I've modified.
cd OHWorkspace/; git-ws st
(st == status)- returns a human-readable list of changes
After I review changes, it's time to commit.
git-ws gitg -c
orgit-ws do "open your favorite GUI here"
(this opens gitg in every repo with changes to commit)
I use gitg to make my commits.
git-ws push -a; git-ws sub au
(these two commands save a lot of time: first, all staged commits in ahead repos are pushed to GitHub - then, every submodule is recursively pulled, updated, and pushed, so that the online submodules are up-to-date)