Files
git-cli/README.md
T

50 lines
1.4 KiB
Markdown

# git
A small command-line-like Git module for Racket, implemented directly on top of the `libgit2` package.
```racket
(require git)
(git 'help)
(git 'help 'grep)
(git 'status)
(git 'diff)
(git 'diff '--cached)
(git 'add "main.rkt" "info.rkt")
(git 'restore '--staged "scratch.rkt")
(git 'reset 'HEAD "--" "main.rkt")
(git 'grep '-i '-n "todo")
(git 'commit "Implement raco support")
(git 'tag "v0.2")
(git 'branch-current)
(git 'switch "main")
;; Display-oriented variant:
(dgit 'status)
```
`git` is an ordinary procedure; command names are symbols. `dgit` performs the
same operation, displays a compact human-readable result, and returns that result.
`(git 'help)` opens the locally installed Scribble documentation. A command can
be supplied to jump directly to its section, for example `(git 'help 'restore)`
or `(git 'help 'grep)`.
For `grep`, the natural `(git 'grep '-i "pattern")` spelling is supported even
though Racket's reader represents `-i` as the complex number `0-1i`; in grep
option position that value is interpreted as Git's `-i` flag.
The same operations are available as normal procedures such as `git-status`, `git-add`, `git-commit`, `git-tag`, `git-current-branch`, `git-switch`, and `git-checkout`.
## Help
Open the locally installed Scribble documentation through Racket's
documentation cross-reference index:
```racket
(git 'help)
(git 'help 'grep)
(git 'help 'restore)
```