当向gopkg.in发送拉取请求时,请提供开发仓库
当在GitHub上进行了原始开发,并且想要向gopkg.in管理的存储库发送pull request时,会遇到以下问题。
■ 常规的公关活动
如果将[github.com/go-redis/redis](https://github.com/go-redis/redis)库fork到[github.com/yyoshiki41/redis](https://github.com/yyoshiki41/redis),则可以在本地机器上的$GOPATH/src/github.com/yyoshiki41/redis目录下进行开发。
问题所在
如果按照以下方式进行开发,
$ cd $GOPATH/src/github.com/yyoshiki41/redis
$ vim redis.go
在各个地方都存在以下类似的import语句,在我的存储库中做的更改差异无法合并的问题面前。
import "gopkg.in/redis.v5/internal"
将”gopkg.in/redis.v5″的部分统一替换为”github.com/yyoshiki41/redis”也不可行,
甚至在”gopkg.in/redis”下进行开发并创建补丁文件也不可行。
■ 解决办法
在 gopkg.in 上添加同步自己的仓库。
操作步骤
去拿一下
$ go get gopkg.in/ORIGINAL_REPOSITORY
在GitHub上复制
将 https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY 进行fork,并添加到自己的仓库中。
添加同步仓库
$ cd $GOPATH/src/gopkg.in/ORIGINAL_REPOSITORY
$ git remote -v
origin https://gopkg.in/ORIGINAL_REPOSITORY (fetch)
origin https://gopkg.in/ORIGINAL_REPOSITORY (push)
# `myrepo`を追加する
$ git remote add myrepo git@github.com:YOUR_USERNAME/YOUR_FORK
$ git remote -v
myrepo git@github.com:YOUR_USERNAME/YOUR_FORK (fetch)
myrepo git@github.com:YOUR_USERNAME/YOUR_FORK (push)
origin https://gopkg.in/ORIGINAL_REPOSITORY (fetch)
origin https://gopkg.in/ORIGINAL_REPOSITORY (push)
4. 将代码推送到远程
$ git checkout -b feature
$ git commit -m "Add feature"
$ git push myrepo feature
用中文进行一次本地化的改写:
顺利完成了向github.com/YOUR_USERNAME/YOUR_FORK的push操作,并创建了拉取请求,一切都已经结束了。
我的repo可以取任何名字,但是请不要取名为upstream,以免产生冲突(考虑到其他要求的情况)。