MCPcopy Create free account
hub / github.com/go-git/go-git / ExampleRepository_CreateRemote

Function ExampleRepository_CreateRemote

example_test.go:140–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138}
139
140func ExampleRepository_CreateRemote() {
141 r, _ := git.Init(memory.NewStorage(), nil)
142
143 // Add a new remote, with the default fetch refspec
144 _, err := r.CreateRemote(&config.RemoteConfig{
145 Name: "example",
146 URLs: []string{"https://github.com/git-fixtures/basic.git"},
147 })
148
149 if err != nil {
150 log.Fatal(err)
151 }
152
153 list, err := r.Remotes()
154 if err != nil {
155 log.Fatal(err)
156 }
157
158 for _, r := range list {
159 fmt.Println(r)
160 }
161
162 // Example Output:
163 // example https://github.com/git-fixtures/basic.git (fetch)
164 // example https://github.com/git-fixtures/basic.git (push)
165}

Callers

nothing calls this directly

Calls 4

NewStorageFunction · 0.92
CreateRemoteMethod · 0.80
RemotesMethod · 0.80
InitMethod · 0.65

Tested by

no test coverage detected