构建和运行 Go 项目的一个分支。

huangapple go评论92阅读模式
英文:

building and running a branch of a go project

问题

这个链接上的博客文章介绍了如何为一个Go语言项目做贡献的指南,考虑到使用go get命令获取项目时可能出现的导入路径问题。根据这些指南,我已经创建了一个名为mybranch的分支,但是当我执行go build并运行程序时,它运行的是主分支而不是mybranch。我应该如何构建和运行特定的分支?当我执行go build并运行程序时,它运行的是主分支上的代码。

以下是具体的步骤:

  1. Fork这个项目。
  2. 获取原始项目:go get github.com/creack/termios
  3. 进入目录:cd $GOPATH/src/github.com/creack/termios
  4. 添加新的远程仓库:git remote add gcharmes git@github.com:gcharmes/termios.git
  5. 从GitHub上获取所有内容:git fetch --all
  6. 在一个新的分支上进行切换:git checkout -b mybranch
  7. 进行贡献,在原始的检出状态下,所有路径都是正确的。
  8. 提交并推送更改:git commit -p && git push gcharmes mybranch
  9. 前往GitHub创建拉取请求。
英文:

Blog article at this link presents the following instructions for contributing to a Go lang project taking into consideration the complications that arise with import paths when you go get a project. I have created a mybranch according to the following instructions, but when I do go build and run the program it is running the master branch, not mybranch. How do I build and run a particular branch? When I do go build and run the program, it's running the code on master branch.

1.Fork the project
2.get the original one go get github.com/creack/termios
3.cd $GOPATH/src/github.com/creack/termios
4.Add the new remote: git remote add gcharmes git@github.com:gcharmes/termios.git
5.Fetch everything from github git fetch --all
6.Checkout in a new branch git checkout -b mybranch
7.7Contribute, as we are on the original checkout, all the paths are correct
8.Commit and push git commit -p && git push gcharmes mybranch
9.Go to github and create the pull request.

答案1

得分: 1

这篇文章是关于从你的分支构建一个 PR(拉取请求),而不是运行 go get <yourfork>(因为该 PR 是发布在一个分支上的)。

正如文章中提到的:

仅将你的分支作为远程占位符使用,不要在本地使用它。

所以你将你的 PR 作为一个专用分支推送到你的分支,并从那里创建你的 PR。

但是,在你的 PR 被接受并合并到 master 分支之前,go get <original_repo> 是不起作用的。

英文:

The article is for building a PR (pull request) from your fork, not for running go get &lt;yourfork&gt; (since that PR is pubished on a branch).

As the article mention:

> Use your fork only as remote placeholder, do not use it locally.

So you push your PR as a dedicated branch to your fork, and make your PR from there.

But a go get &lt;original_repo&gt; won't work until your PR has been accepted and merged on master.

huangapple
  • 本文由 发表于 2014年11月16日 22:07:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/26957834.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定