node-gitm : A simple but useful tool to manage multiple git repositories.

简介:

gitm

NPM Version
NPM Downloads

Introduction

A simple but useful tool to manage multiple git repositories.
Be similar to repo, git submodule.

https://github.com/snowdream/node-gitm

System requirements

Node.js v0.12.0+

Installation

npm install gitm -g

Scene

Scene One

Scene One

If you have a project A on the left.
Now, you want to modularize it to the project A on the right.

For the project A on the left, It is a git repository.
For the project A on the right, project A is not a git repository, project Main and project Module ** are all git repositories.

Browse the example at repositories

Scene Two

Scene One

If you have a project B on the left.
Now, you want to modularize it to the project B on the right.

For the project B on the left, It is a git repository.
For the project B on the right, project B, project Main and project Module ** are all git repositories.

Browse the example at repository

Config

Usually, gitm needs two config files. repo.gitm and branch.gitm

repo.gitm

repo.gitm

  1. repository, required,represent the outermost project is a git repository.
  2. url, required,represent url for the git repository.
  3. branches, optional,represent local branches for the git repository. the first branch will be the default branch.
  4. name, optional,represent local name for the git repository. if this is not provided, then try to guess it from the url.
  5. repositories, optional,represent the git repository has sub git repositories.

branch.gitm

branch.gitm

  1. new/develop/master, required,represent the group name of the branches.
  2. gitmA, required,represent local name for the git repository.
  3. new:develop, new is required,develop is optional,new represent local branch for the git repository. develop represent the local branch new may be created from the branch develop or the branch origin/develop.

Usage

Warning: All the commands as follows should be executed in the root path.
For Scene One, the root path is Project A.
For Scene Two, the root path is Project B.

gitm init

  • If repo.gitm does not exist in the root path, try to create it.
  • If branch.gitm does not exist in the root path, try to create it.
  • If .gitignore does not exist in every git repository, try to create it. If sub git repository exist, try to add them name into the file .gitignore.

gitm clone

gitm clone

Read the file repo.gitm in the current directory, and clone every git repository.
If the property branches exist, every branch will be checkout. The fisrt branch will be the default branch.

gitm clone https://raw.githubusercontent.com/snowdream/gitm/master/examples/repository/repo.gitm

Read the file repo.gitm from the url, other operation is the same as the command gitm clone

gitm checkout [name]

Check the file branch.gitm,if the name does not exist in the names of group, then git checkout [name] will be executed in every git repository.else deal it with the following rules.
gitm checkout

gitm checkout new

git checkout new will be executed in every git repository. such as gitmA.

  1. if the branch new exist, excute git checkout new
  2. if the branch origin/new exist, excute git checkout –b new origin/new
  3. if the branch develop exist, excute git checkout –b new develop
  4. if the branch origin/develop exist, excute git checkout –b new origin/develop
  5. if all the branch up does not exist, excute git checkout –b new

All the steps will be taken in order. once a step has been taken, then the command is finished, and the rest steps will not be taken.

gitm fetch

gitm fetch

Check the file repo.gitm,execute the following command in every git repository.

git fetch --all --progress -v

If gitm fetch has any other parameters, such as gitm fetch origin master
Then git fetch origin master will be executed in every git repository.

gitm pull

gitm pull

Check the file repo.gitm,execute the following command in every git repository.

git pull origin branch --progress -v

branch is the current branch of the git repository.

If gitm pull has any other parameters, such as gitm pull origin master
Then git pull origin master will be executed in every git repository.

gitm push

gitm push

Check the file repo.gitm,execute the following command in every git repository.

git push origin branch:branch --progress -v

branch is the current branch of the git repository.

If gitm push has any other parameters, such as gitm push origin master
Then git push origin master will be executed in every git repository.

gitm help [cmd]

Such as gitm help clone. It will execute the following command only once.

git help clone

gitm -h / gitm --help

show helps for gitm

gitm -V / gitm --version

show version for gitm

Other git commands which have not been list here, such as gitm tag v0.1

Use git in place of gitm, then execute the command in every git repository.

License

Copyright (C) 2015 Snowdream Mobile <yanghui1986527@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
相关文章
|
JSON 前端开发 JavaScript
前端AJAX入门到实战,学习前端框架前必会的(ajax+node.js+webpack+git)(一)
前端AJAX入门到实战,学习前端框架前必会的(ajax+node.js+webpack+git)(一)
590 0
|
JavaScript Shell 开发工具
vue项目 git上传忽略node_modules和dist
vue项目 git上传忽略node_modules和dist
709 0
|
3月前
|
JavaScript IDE 前端开发
前端开发工具配置 nodejs & git & IDE
前端开发工具配置 nodejs & git & IDE
|
5月前
|
JavaScript Ubuntu Linux
蓝易云 - linux中安装nodejs,卸载nodejs,更新nodejs,git
请根据自己的Linux发行版和版本选择合适的命令。
214 2
|
开发工具 git
project is registered as a Git root, but no Git repositories were found there
报错如下 我一开始想把项目推到git,但是发现右键没有git选项。于是我去搜为什么右键没git选项。给出的答案就是在版本控制中添加。 上图这个我添加的本身就是一个git项目,所以没有出现问题,但是如果本身项目还没有关联远程仓库的话,这样搞是会出现问题。
796 0
project is registered as a Git root, but no Git repositories were found there
|
4月前
|
开发工具 数据安全/隐私保护 git
为了方便项目打包,我用Node写了个git-tag工具
为了方便项目打包,我用Node写了个git-tag工具
90 0
|
4月前
|
开发工具 git
vscode设置 git提交代码忽略node_modules,dist,vscode如何设置不提交node_modules,dist
vscode设置 git提交代码忽略node_modules,dist,vscode如何设置不提交node_modules,dist
482 0
|
6月前
|
JavaScript 持续交付 开发工具
Git自动化利器:使用Node.js脚本定制化提交消息处理
Git自动化利器:使用Node.js脚本定制化提交消息处理
157 0
|
Linux 开发工具 git
Linux系统使用Git仓库安装Nvm工具并安装Npm和Node
Linux系统使用Git仓库安装Nvm工具并安装Npm和Node
482 0
|
JavaScript Java 关系型数据库
Mac不会用?玩转brew,部署web开发环境【jdk、git、msyql、maven、node】全家桶,前后端覆盖
Mac不会用?玩转brew,部署web开发环境【jdk、git、msyql、maven、node】全家桶,前后端覆盖
1144 0
Mac不会用?玩转brew,部署web开发环境【jdk、git、msyql、maven、node】全家桶,前后端覆盖