英文:
Submit pull request for changes to packages installed via "go get"
问题
我通过go get github.com/<other_user>/<repository>
安装了一个包。由于缺少一些功能,所以我一直在与原作者合作,将这些功能添加到包中。
我在本地副本中进行了更改并提交了它们。然后我意识到:糟糕,我没有权限来git push
这些更改。
我是否有办法挽救我的更改并以某种方式向他提交一个拉取请求?还是我必须放弃所有的更改,fork他的存储库,重新实现我的更改,然后提交一个拉取请求?
无论我做什么,是否有办法保留执行以下命令的能力?
go get -u <original_repository>
还是我必须成为一个全职贡献者,并不断更新我的fork与他的存储库保持同步?
英文:
I have a package I installed via go get github.com/<other_user>/<repository>
. It was missing some features, so I have been working with the original author to add them to the package.
I made the changes to my local copy and committed them. Then I realized: derp, I don't have authorization to git push
these changes.
Is there a way for me to salvage my changes and somehow submit a pull request to him? Or do I have to lose all my changes, fork his repository, re-implement my changes, and then submit a pull request?
And no matter what I do, is there a way for me to retain the ability to do this command?
go get -u <original_repository>
Or do I have to just become a full-time contributor and continually update my fork with his repository?
答案1
得分: 4
在GitHub上fork仓库,然后将你的fork添加为你的工作副本中的一个远程仓库,名称可以不是origin,例如 git remote add myfork git@github.org...
。你可以将你的更改推送到你的fork (git push myfork
),然后从你的fork向原始仓库打开一个PR。
具体来说,在你将原始仓库fork到你自己的账户后,命令应该像这样:
git remote add myfork https://github.com/<你的用户名>/<仓库名>.git
git push myfork
之后,你可以将PR提交到原始仓库。如果你的PR被接受,你可以运行以下命令:
git remote remove myfork
git rebase master
git pull origin master
然后你可以从你的GitHub账户中删除你的fork。之后,go get -u
将正常工作。
每当你需要对包进行新的更改时,你可以重复这个过程。
英文:
Fork the repo in GitHub, then add your fork as a remote in your working copy under a name other than origin, e.g. git remote add myfork git@github.org...
. You can push your changes to your fork (git push myfork
), then open a PR from your fork to the original.
Explicitly, the commands would something like this after you fork the original to your own account:
git remote add myfork https://github.com/<your_username>/<repository>.git
git push myfork
After which, you can submit the PR to the original. If your PR is accepted, you can then run these commands:
git remote remove myfork
git rebase master
git pull origin master
You can then delete your fork from your GitHub account. After which, go get -u
will function as normal.
Any time you need to make new changes to the package, you can repeat this process.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论