git-nez
A simple alternative to git submodules and npm linking.
Current version
0.0.2
Pending functionality
- push across all nested repos with commits pending
- pull across all repos
Install
sudo npm install git-nez -g
Usage
Step 0
git nez -h
Step 1 - init
- This recurses for nested git repos starting at
.
or--root /home/me/git/faraway_tree
. - It generates a control file
.nez_tree
containing details of the found repos. - The
.nez_tree
should be committed. - It enables others in the team to generate an identical tree of cloned repos.
> git nez init scanning
Step 2 - status
- This step is being performed at another workstation
- Only the root repo has been checked out there.
- It uses the
.nez_tree
control file to report on the status across all nested repositories that should be and/or are present.
> git nez status
Step 3 - clone
- This clones all the missing repositories.
- It also checkouts the branches as specified in the
.nez_tree
control file
> git nez clone all missing repositories in . already cloned . mkdir -p ./node/node_modules/brix git clone git@github.com:nomilous/brix.git ./node/node_modules/brixCloning into './node/node_modules/brix'... mkdir -p ./node/node_modules/brix/node_modules/trix git clone git@github.com:nomilous/trix.git ./node/node_modules/brix/node_modules/trixCloning into './node/node_modules/brix/node_modules/trix'... git --git-dir=./node/node_modules/brix/node_modules/trix/.git --work-tree=./node/node_modules/brix/node_modules/trix checkout feature/testSwitched to a new branch 'feature/test'Branch feature/test set up to track remote branch feature/test from origin. mkdir -p ./node_modules/nez git clone git@github.com:nomilous/nez.git ./node_modules/nezCloning into './node_modules/nez'... git --git-dir=./node_modules/nez/.git --work-tree=./node_modules/nez checkout developBranch develop set up to track remote branch develop from origin.Switched to a new branch 'develop' mkdir -p ./root/node_modules/elix git clone git@github.com:nomilous/elix.git ./root/node_modules/elixCloning into './root/node_modules/elix'... git --git-dir=./root/node_modules/elix/.git --work-tree=./root/node_modules/elix checkout developSwitched to a new branch 'develop'Branch develop set up to track remote branch develop from origin. > # # doing it again has the expected result # > git nez clone all missing repositories in . already cloned . already cloned ./node/node_modules/brix already cloned ./node/node_modules/brix/node_modules/trix already cloned ./node_modules/nez already cloned ./root/node_modules/elix >
Important point
- The
.nez_tree
control file specifies the branch that each repo should be on. - Running a clone will checkout that branch
> cd ./node/node_modules/brix/node_modules/trix> git checkout master> cd -> git nez clone all missing repositories in . already cloned . already cloned ./node/node_modules/brix already cloned ./node/node_modules/brix/node_modules/trix git --git-dir=./node/node_modules/brix/node_modules/trix/.git --work-tree=./node/node_modules/brix/node_modules/trix checkout feature/testSwitched to branch 'feature/test' already cloned ./node_modules/nez already cloned ./root/node_modules/elix
Step 4 - status
- After modification in one of the nested modules
> git nez status
Step 5 - commit
- First it should be pointed out that this commit will enact a commit across all repos that have pending files staged (ie. files that were
git add <file>
ed) - This global commit may therefore not be ideal because it commits with a common log message for all.
- It is suggested that in most cases commits should be done manually in each repo
> cd ./root/node_modules/elix> git add requirements/manageability.coffee > cd ../../ > git nez commit -m 'it propagates a config hup into the tree' on all repositories with staged changes in . no staged changes in . no staged changes in ./node/node_modules/brix no staged changes in ./node/node_modules/brix/node_modules/trix no staged changes in ./node_modules/nez git --git-dir=./root/node_modules/elix/.git --work-tree=./root/node_modules/elix commit -m it propagates a config hup into the tree[develop 74d5db8] it propagates a config hup into the tree 1 file changed, 1 insertion > # # the new status as expected # > git nez status
Important point
- It may be that one of your repos has forgetccidentally been left checkedout on the wrong branch (according to the
.nez_tree
control file) - The commit run will report this case of affairs and take no further action for that repo.
> cd ./root/node_modules/elix> git checkout master> cd -> git nez commit -m 'shared commit log message' on all repositories with staged changes in . no staged changes in . no staged changes in ./node/node_modules/brix no staged changes in ./node/node_modules/brix/node_modules/trix no staged changes in ./node_modules/nez ./root/node_modules/elix SHOULD BE ON BRANCH refs/heads/develop NOT refs/heads/master