此博客文章 link考虑到当您 go get
项目时导入路径出现的复杂情况,提供了以下为 Go lang 项目做贡献的说明。我已经根据以下说明创建了一个 mybranch
,但是当我执行 go build
并运行程序时,它正在运行 master 分支,而不是 mybranch
。如何构建和运行特定分支?当我执行 go build
并运行程序时,它在 master
分支上运行代码。
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.
最佳答案
本文用于从您的分支构建 PR( pull 请求),而不是用于运行 go get <yourfork>
(因为该 PR 是在分支上发布的)。
正如文章提到的:
Use your fork only as remote placeholder, do not use it locally.
因此,您将您的 PR 作为专用分支推送到您的 fork ,并从那里创建您的 PR。
但是一个go get <original_repo>
在您的 PR 在 master
上被接受并 merge 之前不会起作用.
关于git - 构建并运行一个 go 项目的分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26957834/