+1
COMPATIBILITY.md
+1
COMPATIBILITY.md
···
34
| `merge` | | ⚠️ (partial) | Fast-forward only | |
35
| `mergetool` | | ❌ | | |
36
| `stash` | | ❌ | | |
37
+
| `sparse-checkout` | | ✅ | | - [sparse-checkout](_examples/sparse-checkout/main.go) |
38
| `tag` | | ✅ | | - [tag](_examples/tag/main.go) <br/> - [tag create and push](_examples/tag-create-push/main.go) |
39
40
## Sharing and updating projects
+1
_examples/common_test.go
+1
_examples/common_test.go
+31
_examples/sparse-checkout/main.go
+31
_examples/sparse-checkout/main.go
···
···
1
+
package main
2
+
3
+
import (
4
+
"os"
5
+
6
+
"github.com/go-git/go-git/v5"
7
+
. "github.com/go-git/go-git/v5/_examples"
8
+
)
9
+
10
+
func main() {
11
+
CheckArgs("<url>", "<sparse_path>", "<directory>")
12
+
url := os.Args[1]
13
+
path := os.Args[2]
14
+
directory := os.Args[3]
15
+
16
+
Info("git clone %s %s", url, directory)
17
+
18
+
r, err := git.PlainClone(directory, false, &git.CloneOptions{
19
+
URL: url,
20
+
NoCheckout: true,
21
+
})
22
+
CheckIfError(err)
23
+
24
+
w, err := r.Worktree()
25
+
CheckIfError(err)
26
+
27
+
err = w.Checkout(&git.CheckoutOptions{
28
+
SparseCheckoutDirectories: []string{path},
29
+
})
30
+
CheckIfError(err)
31
+
}