A CLI tool to generate Git repositories with specific configuration and commit histories, to quickly test your Git tools and workflows.
npx git-repo-generatorwill generate in the current directory a Git repository with
- A
mainbranch - A
test.txtfile in the working directory - 3 commits
1--2--3 main
npx git-repo-generator --dir repo-test --commits 5| Option | Description |
|---|---|
-d --dir |
Directory of Git repository (default: . current directory ) |
-c --commits |
Number of commits (default: 3) Ignored if --file is provided (see below) |
-f --file |
Configuration file (see below) |
-h --help |
Display command doc |
You can provide a YAML file that describes your Git repo configuration and history
npx git-repo-generator -d repo-test -f git.yamllog:
- init
- create file test.txt
- commit
- branch develop
- checkout develop
- create file test2.txt
- commit
- checkout main
- merge develop
- tag v1.0will generate the following Git repository
--2-- < develop
/ \
1-------3 < main < v1.0
log:
- init:
defaultBranch: main
- create file:
file: test.txt
content: line 1
- commit:
message: first commit
author: user1
email: user1@example.com
- branch develop
- checkout develop
- change content:
file: test.txt
content: |
line 1
line 2
- commit
- checkout main
- merge:
theirs: develop
message: merge commit
- tag:
name: v1.0
annotated: true
conf:
author: user
email: user@example.com| Command | Expressions | Notes |
|---|---|---|
| Init repository | - init - init: |
If omitted: - defaultBranch = "main" |
| Commit | - commit - commit: |
Equivalent of git add -a & git commit (stage all changes in the working dir before committing).If omitted: - message = "commit <#>" - author = conf.author ?? "user-test"- email = conf.email ?? "user-test@example.com" |
| Create branch | - branch develop |
|
| Checkout | - checkout develop |
|
| Merge | - merge develop - merge: |
If omitted: - message = "merge branch <theirs>" - author = conf.author ?? "user-test"- email = conf.email ?? "user-test@example.com"Merges never fast-forward. Merge conflicts are auto-resolved cleanly by favoring the "theirs" branch. |
| Tag | - tag v1.0 - tag: |
By default, creates a lightweight tag, unless annotated: trueIf omitted: - annotated = false- message = "create tag <name>" - author = conf.author ?? "user-test"- email = conf.email ?? "user-test@example.com" |
| Create file | - create file src/test.txt - create file: - create file: |
If omitted: - content = <file name> |
| Change content | - change content: |
conf:
author: user # Default commit author name
email: user@example.com # Default commit author email- isomorphic-git: for working with Git repositories (Great project. Check it out!)