initialcommit-com / git-sim
- четверг, 26 января 2023 г. в 00:37:52
Visually simulate Git operations in your own repos with a single terminal command.
Visually simulate Git operations in your own repos with a single terminal command.
This generates an image (default) or video visualization depicting the Git command's behavior.
Command syntax is based directly on Git's command-line syntax, so using git-sim is as familiar as possible.
Example: $ git-sim merge <branch>
log
, status
, add
, restore
, commit
, stash
, branch
, tag
, reset
, revert
, merge
, rebase
, cherry-pick
--animate
flag (note: significant performance slowdown, it is recommended to use --low-quality
to speed up testing and remove when ready to generate presentation-quality video)Install git-sim
:
$ pip3 install git-sim
Note: For MacOS, it is recommended to NOT use the system Python to install Git-Sim, and instead use Homebrew to install a version of Python to work with Git-Sim. Virtual environments should work too.
$ cd path/to/git/repo
$ git-sim [global options] <subcommand> [subcommand options]
Simulated output will be created as a .jpg
file. Output files are named using the subcommand executed combined with a timestamp, and by default are stored in a subdirectory called git-sim_media/
. The location of this subdirectory is customizable using the command line flag --media-dir=path/to/output
. Note that when the --animate
global flag is used, render times will be much longer and a .mp4
video output file will be produced.
See global help for list of global options/flags and subcommands:
$ git-sim -h
$ git-sim <subcommand> -h
Basic usage is similar to Git itself - git-sim
takes a familiar set of subcommands including "log", "status", "add", "restore", "commit", "stash", "branch", "tag", "reset", "revert", "merge", "rebase", "cherry-pick", along with corresponding options.
$ git-sim [global options] <subcommand> [subcommand options]
The [global options]
apply to the overarching git-sim
simulation itself, including:
--light-mode
: Use a light mode color scheme instead of default dark mode.
--animate
: Instead of outputting a static image, animate the Git command behavior in a .mp4 video.
--reverse
: Display commit history in the reverse direction.
Animation-only global options (to be used in conjunction with --animate
):
--speed=n
: Set the multiple of animation speed of the output simulation, n
can be an integer or float, default is 1.
--low-quality
: Render the animation in low quality to speed up creation time, recommended for non-presentation use.
--show-intro
: Add an intro sequence with custom logo and title.
--show-outro
: Add an outro sequence with custom logo and text.
--title=title
: Custom title to display at the beginning of the animation.
--logo=logo.png
: The path to a custom logo to use in the animation intro/outro.
--outro-top-text
: Custom text to display above the logo during the outro.
--outro-bottom-text
: Custom text to display below the logo during the outro.
The [subcommand options]
are like regular Git options specific to the specified subcommand (see below for a full list).
The following is a list of Git commands that can be simulated and their corresponding options/flags.
Usage: git-sim log
Usage: git-sim status
Usage: git-sim add <file 1> <file 2> ... <file n>
<file>
as a modified working directory file, or an untracked fileUsage: git-sim restore <file 1> <file 2> ... <file n>
<file>
as a modified working directory file, or staged fileUsage: git-sim commit -m "Commit message"
Usage: git-sim stash <file>
<file>
as a modified working directory file, or staged file<file>
is specified, all available working directory and staged files will be includedUsage: git-sim branch <new branch name>
<new branch name>
as the name of the new branch to simulate creation ofUsage: git-sim tag <new tag name>
<new tag name>
as the name of the new tag to simulate creation ofUsage: git-sim reset <reset-to> [--mixed|--soft|--hard]
<reset-to>
as any commit id, branch name, tag, or other ref to simulate reset to from the current HEAD (default: HEAD
)--mixed
, but can be specified using --soft
, --hard
, or --mixed
Usage: git-sim revert <to-revert>
<to-revert>
as any commit id, branch name, tag, or other ref to simulate revert for<to-revert>
Usage: git-sim merge <branch>
<branch>
as the branch name to merge into the active branch--no-ff
Usage: git-sim rebase <new-base>
<new-base>
as the branch name to rebase the active branch ontoUsage: git-sim cherry-pick <commit>
<commit>
as a ref (branch name/tag) or commit ID to cherry-pick onto the active branch$ git-sim --animate reset HEAD^
$ git checkout main
$ git-sim --animate merge dev
$ git checkout dev
$ git-sim --animate rebase main
$ git checkout main
$ git-sim --animate cherry-pick dev
Simulate the output of the git log command:
$ cd path/to/git/repo
$ git-sim log
Simulate the output of the git status command:
$ git-sim status
Simulate adding a file to the Git staging area:
$ git-sim add filename.ext
Simulate restoring a file from the Git staging area:
$ git-sim restore filename.ext
Simulate creating a new commit based on currently staged changes:
$ git-sim commit -m "Commit message"
Simulate stashing all working directory and staged changes:
$ git-sim stash
Simulate creating a new Git branch:
$ git-sim branch new-branch-name
Simulate creating a new Git tag:
$ git-sim tag new-tag-name
Simulate a hard reset of the current branch HEAD to the previous commit:
$ git-sim reset HEAD^ --hard
Simulate reverting the changes in an older commit:
$ git-sim revert HEAD~7
Simulate merging a branch into the active branch:
$ git-sim merge feature1
Simulate rebasing the active branch onto a new base:
$ git-sim rebase main
Simulate cherry-picking a commit from another branch onto the active branch:
$ git-sim cherry-pick 0ae641
Use light mode for white background and black text, instead of the default black background with white text:
$ git-sim --light-mode status
Animate the simulated output as a .mp4 video file:
$ git-sim --animate add filename.ext
Add an intro and outro with custom text and logo (must include --animate
):
$ git-sim --animate --show-intro --show-outro --outro-top-text="My Git Repo" --outro-bottom-text="Thanks for watching!" --logo=path/to/logo.png status
Customize the output image/video directory location:
$ git-sim --media-dir=path/to/output status
Generate output video in low quality to speed up rendering time (useful for repeated testing, must include --animate
):
$ git-sim --animate --low-quality status
See Quickstart section for details on installing manim and other dependencies. Then run:
$ pip3 install git-sim
Learn more about this tool on the git-sim project page.
Jacob Stopak - on behalf of Initial Commit