# README
Gitgud
A tiny library to run git commands.
Sometimes working with exec.Cmd
might not be easy as expected. Here gitgud comes to help you.
Every command has a standard Runnable
output. It is similar to the exec.Cmd
interface but with some tweaking.
If you need more customisation you can always use the original exec.Cmd
instance and tweak it yourself.
Features
- Ease of use
- Handle command errors
- Supports custom
stderr
,stdout
andstdin
- Run directly in the terminal with
RunInTerminal
Usage
go get -u github.com/rawnly/gitgud
package main
import (
"fmt"
"github.com/rawnly/gitgud/git"
)
func main() {
// equivalent to "git status -s"
status, err := git.Status(&git.StatusOptions{
Short: true,
}).Output()
if err != nil {
panic(err.Error())
}
fmt.Println(status)
}
Advanced Example
package main
import "github.com/rawnly/gitgud/git"
import "os"
func main() {
diffCmd := git.Commit("docs(readme): updated example", nil)
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
diffCmd.Cmd.Stdout = stdout
diffCmd.Cmd.Stderr = stderr
if err := diffCmd.Run(); err != nil {
panic(err)
}
}
Available Commands
Start a working area
- Clone
- Init
Work on the current change
- Add (partially done)
- Mv
- Restore
- Rm
Examine the history and state
- Bisect
- Diff
- Grep
- Log
- Show
- Status
Grow, mark and tweak your common history
- Branch
- Commit
- Merge
- Rebase
- Reset
- Switch
- Tag
Collaborate
- Fetch
- Push
- Pull
Others
- Config, SetConfig