英文:
building and running a branch of a go project
问题
这个链接上的博客文章介绍了如何为一个Go语言项目做贡献的指南,考虑到使用go get命令获取项目时可能出现的导入路径问题。根据这些指南,我已经创建了一个名为mybranch的分支,但是当我执行go build并运行程序时,它运行的是主分支而不是mybranch。我应该如何构建和运行特定的分支?当我执行go build并运行程序时,它运行的是主分支上的代码。
以下是具体的步骤:
- Fork这个项目。
- 获取原始项目:
go get github.com/creack/termios。 - 进入目录:
cd $GOPATH/src/github.com/creack/termios。 - 添加新的远程仓库:
git remote add gcharmes git@github.com:gcharmes/termios.git。 - 从GitHub上获取所有内容:
git fetch --all。 - 在一个新的分支上进行切换:
git checkout -b mybranch。 - 进行贡献,在原始的检出状态下,所有路径都是正确的。
- 提交并推送更改:
git commit -p && git push gcharmes mybranch。 - 前往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 <yourfork> (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 <original_repo> won't work until your PR has been accepted and merged on master.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论