diff --git a/src/index.md b/src/index.md index 9b41bc8..20dc4ef 100644 --- a/src/index.md +++ b/src/index.md @@ -13,12 +13,12 @@ go-git is a highly extensible Git implementation in pure Go. This documentation ```go import ( - "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v6" ) func main() { // Clone repository - repo, err := git.PlainClone("/path/to/repo", false, &git.CloneOptions{ + repo, err := git.PlainClone("/path/to/repo", &git.CloneOptions{ URL: "https://github.com/go-git/go-git", }) } diff --git a/src/tutorials/getting-started.md b/src/tutorials/getting-started.md index 5cfd14f..71ec3aa 100644 --- a/src/tutorials/getting-started.md +++ b/src/tutorials/getting-started.md @@ -16,7 +16,7 @@ operations using the latest version of go-git. The following example shows how to clone a Git repository to your local filesystem: ```go -r, err := git.PlainClone("/path/to/repo", false, &git.CloneOptions{ +r, err := git.PlainClone("/path/to/repo", &git.CloneOptions{ URL: "https://github.com/go-git/go-git", }) ``` diff --git a/src/tutorials/troubleshooting.md b/src/tutorials/troubleshooting.md index 1e7d1c4..ea4fa57 100644 --- a/src/tutorials/troubleshooting.md +++ b/src/tutorials/troubleshooting.md @@ -4,12 +4,36 @@ title: Troubleshooting --- # Troubleshooting -## SSH connections +This guide covers common issues encountered when using go-git. -To enable trace information for SSH handshakes, use the `GIT_TRACE_SSH` -environment variable: +## Debugging and Tracing +### Available Trace Options + +go-git supports different tracing levels. Enable them by calling `trace.SetTarget`: + +```golang +import `github.com/go-git/go-git/v6/utils/trace` + +... + +trace.SetTarget(trace.SSH | trace.Performance) +``` + +Here are the current trace options: + +- General: General traces general operations. +- Packet: Packet traces git packets. +- SSH: SSH handshake operations. This does not have a direct translation to an upstream trace option. +- Performance: performance information for specific go-git operations. +- HTTP: HTTP operations and requests. ``` + +### SSH Connection Issues + +To enable trace information for SSH handshakes, use the `GIT_TRACE_SSH` environment variable: + +```bash $ GIT_TRACE_SSH=true go run _examples/clone/main.go git@github.com:go-git/go-git /tmp/go-git 19:09:14.134147 common.go:43: ssh: Using default auth builder (user: git) 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 19:09:14.134577 common.go:155: ssh: host key algorithms [ssh-ed25519] 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" ``` + +## Common Errors and Solutions + +### Performance Issues + +#### Large Repository Cloning +**Problem:** Slow clone times for large repositories + +**Solutions:** +1. Use shallow clone: + ```go + _, err := git.PlainClone("/path", &git.CloneOptions{ + URL: "https://github.com/user/repo", + Depth: 1, // Only fetch latest commit + }) + ``` + +2. Clone single branch: + ```go + _, err := git.PlainClone("/path", &git.CloneOptions{ + URL: "https://github.com/user/repo", + SingleBranch: true, + ReferenceName: plumbing.NewBranchReferenceName("main"), + }) + ``` + +3. Skip tags when not needed: + ```go + _, err := git.PlainClone("/path", &git.CloneOptions{ + URL: "https://github.com/user/repo", + NoTags: true, + }) + ``` + +## Getting Help + +If you encounter issues not covered here: + +1. Check the [examples directory](https://github.com/go-git/go-git/tree/main/_examples) for usage patterns +2. Enable tracing to get detailed debug information +3. Review the [GitHub issues](https://github.com/go-git/go-git/issues) for similar problems +4. Create a minimal reproduction case when reporting bugs