Skip to content

Commit 4d0ed85

Browse files
authored
Merge pull request #1 from go-git/update
Update syntax and improve troubleshooting section
2 parents 125b671 + 660c7fb commit 4d0ed85

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ go-git is a highly extensible Git implementation in pure Go. This documentation
1313

1414
```go
1515
import (
16-
"github.com/go-git/go-git/v5"
16+
"github.com/go-git/go-git/v6"
1717
)
1818

1919
func main() {
2020
// Clone repository
21-
repo, err := git.PlainClone("/path/to/repo", false, &git.CloneOptions{
21+
repo, err := git.PlainClone("/path/to/repo", &git.CloneOptions{
2222
URL: "https://github.com/go-git/go-git",
2323
})
2424
}

src/tutorials/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ operations using the latest version of go-git.
1616
The following example shows how to clone a Git repository to your local filesystem:
1717

1818
```go
19-
r, err := git.PlainClone("/path/to/repo", false, &git.CloneOptions{
19+
r, err := git.PlainClone("/path/to/repo", &git.CloneOptions{
2020
URL: "https://github.com/go-git/go-git",
2121
})
2222
```

src/tutorials/troubleshooting.md

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,36 @@ title: Troubleshooting
44
---
55
# Troubleshooting
66

7-
## SSH connections
7+
This guide covers common issues encountered when using go-git.
88

9-
To enable trace information for SSH handshakes, use the `GIT_TRACE_SSH`
10-
environment variable:
9+
## Debugging and Tracing
1110

11+
### Available Trace Options
12+
13+
go-git supports different tracing levels. Enable them by calling `trace.SetTarget`:
14+
15+
```golang
16+
import `github.com/go-git/go-git/v6/utils/trace`
17+
18+
...
19+
20+
trace.SetTarget(trace.SSH | trace.Performance)
21+
```
22+
23+
Here are the current trace options:
24+
25+
- General: General traces general operations.
26+
- Packet: Packet traces git packets.
27+
- SSH: SSH handshake operations. This does not have a direct translation to an upstream trace option.
28+
- Performance: performance information for specific go-git operations.
29+
- HTTP: HTTP operations and requests.
1230
```
31+
32+
### SSH Connection Issues
33+
34+
To enable trace information for SSH handshakes, use the `GIT_TRACE_SSH` environment variable:
35+
36+
```bash
1337
$ GIT_TRACE_SSH=true go run _examples/clone/main.go git@github.com:go-git/go-git /tmp/go-git
1438
19:09:14.134147 common.go:43: ssh: Using default auth builder (user: git)
1539
19:09:14.134193 sshagent.go:42: ssh: net.Dial unix sock /tmp/ssh-XXXXXXULYg1c/agent.6427
@@ -22,3 +46,45 @@ $ GIT_TRACE_SSH=true go run _examples/clone/main.go git@github.com:go-git/go-git
2246
19:09:14.134577 common.go:155: ssh: host key algorithms [ssh-ed25519]
2347
19:09:14.458332 auth_method.go:330: ssh: hostkey callback hostname=github.com:22 remote=20.26.156.215:22 pubkey="ssh-ed25519 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU"
2448
```
49+
50+
## Common Errors and Solutions
51+
52+
### Performance Issues
53+
54+
#### Large Repository Cloning
55+
**Problem:** Slow clone times for large repositories
56+
57+
**Solutions:**
58+
1. Use shallow clone:
59+
```go
60+
_, err := git.PlainClone("/path", &git.CloneOptions{
61+
URL: "https://github.com/user/repo",
62+
Depth: 1, // Only fetch latest commit
63+
})
64+
```
65+
66+
2. Clone single branch:
67+
```go
68+
_, err := git.PlainClone("/path", &git.CloneOptions{
69+
URL: "https://github.com/user/repo",
70+
SingleBranch: true,
71+
ReferenceName: plumbing.NewBranchReferenceName("main"),
72+
})
73+
```
74+
75+
3. Skip tags when not needed:
76+
```go
77+
_, err := git.PlainClone("/path", &git.CloneOptions{
78+
URL: "https://github.com/user/repo",
79+
NoTags: true,
80+
})
81+
```
82+
83+
## Getting Help
84+
85+
If you encounter issues not covered here:
86+
87+
1. Check the [examples directory](https://github.com/go-git/go-git/tree/main/_examples) for usage patterns
88+
2. Enable tracing to get detailed debug information
89+
3. Review the [GitHub issues](https://github.com/go-git/go-git/issues) for similar problems
90+
4. Create a minimal reproduction case when reporting bugs

0 commit comments

Comments
 (0)