aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-31 14:43:49 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-31 14:43:49 +0100
commit2308066c28d3cbbfb472fb634c3e10a1c7786cfc (patch)
treedd37a1503267981b1f62662baeaa818592bbe4ce
parent09ac55657efcc3bb40db780ce9441095aea0d64c (diff)
downloadgo-git-2308066c28d3cbbfb472fb634c3e10a1c7786cfc.tar.gz
Updated README.md (Fixes #243)
-rw-r--r--README.md40
1 files changed, 33 insertions, 7 deletions
diff --git a/README.md b/README.md
index 5538dd8..5a379fc 100644
--- a/README.md
+++ b/README.md
@@ -27,20 +27,46 @@ go get -u srcd.works/go-git.v4/...
Examples
--------
-Cloning a repository and printing the history of HEAD, just like `git log` does
-
> Please note that the functions `CheckIfError` and `Info` used in the examples are from the [examples package](https://github.com/src-d/go-git/blob/master/examples/common.go#L17) just to be used in the examples.
+### Basic example
+
+A basic example that mimics the standard `git clone` command
+
```go
-// Instances an in-memory git repository
-r := git.NewMemoryRepository()
+// Clone the given repository to the given directory
+Info("git clone https://github.com/src-d/go-git")
+
+_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
+ URL: "https://github.com/src-d/go-git",
+ Progress: os.Stdout,
+})
+
+CheckIfError(err)
+```
+
+Outputs:
+```
+Counting objects: 4924, done.
+Compressing objects: 100% (1333/1333), done.
+Total 4924 (delta 530), reused 6 (delta 6), pack-reused 3533
+```
+
+### In-memory example
-// Clones the given repository, creating the remote, the local branches
-// and fetching the objects, exactly as:
+Cloning a repository into memory and printing the history of HEAD, just like `git log` does
+
+
+```go
+// Clones the given repository in memory, creating the remote, the local
+// branches and fetching the objects, exactly as:
Info("git clone https://github.com/src-d/go-siva")
-err := r.Clone(&git.CloneOptions{URL: "https://github.com/src-d/go-siva"})
+r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
+ URL: "https://github.com/src-d/go-siva",
+})
+
CheckIfError(err)
// Gets the HEAD history from HEAD, just like does: