This is a creation in Article, where the information may have evolved or changed.
Problem
A job was changed in April, and the new job was developed using Golang. When I fork a piece of code in the Code warehouse ready to be developed in my own repo, I find the problem of Golang fork.
SOURCE Repo:example.com/group/tool.git
After fork:example.com/my/tool.git
So I used go get example.com/my/tool
to download my repo preparation work and found that GOPATH
there are still group/tool
. The reason of course is that the import package in the code is used in this way:
import "example/group/tool/module"
So if I'm going to run normally, I have to change it to:
import "example/my/tool/module"
And then you have to change it back before you finish the pull request. This is obviously not the right way to work.
Solve
Having this problem after the Internet search, obviously not only I alone have this problem. This article should be a brief summary of how this should be done.
1. Fork Repo
Fork first and get a repo of your own:example.com/my/tool.git
2. Download the source Repo code
go get example.com/group/tool"
At GOPATH
this time you have all the code and dependencies have been downloaded.
3. Add Remote
Enter the project directory and add remote to git repo
cd $GOPATH/src/example.com/group/toolgit remote add fork example.com/my/tool.git
4. Push
After the previous steps have been completed, the code can be modified, and then the following is the way to push:
git push fork
Reference
- Http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html
- https://splice.com/blog/contributing-open-source-git-repositories-go/