_examples/push/main.go
raw| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | |
| 6 | "gopkg.in/src-d/go-git.v4" |
| 7 | . "gopkg.in/src-d/go-git.v4/_examples" |
| 8 | ) |
| 9 | |
| 10 | // Example of how to open a repository in a specific path, and push to |
| 11 | // its default remote (origin). |
| 12 | func main() { |
| 13 | CheckArgs("<repository-path>") |
| 14 | path := os.Args[1] |
| 15 | |
| 16 | r, err := git.PlainOpen(path) |
| 17 | CheckIfError(err) |
| 18 | |
| 19 | Info("git push") |
| 20 | // push using default options |
| 21 | err = r.Push(&git.PushOptions{}) |
| 22 | CheckIfError(err) |
| 23 | } |