这是使用 git 子模块的合适场景吗?
我对 Git 和 Ruby 都很陌生,但我想知道这种情况是否适合使用 Git 子模块,或者我是否应该使用不同的方法。
我正在从事 Sinatra 项目。我想将一个 gem 与 Github 上托管的代码一起使用。我需要对我的项目的 gem 进行一些更改。 (基本上,gem 用于处理某种文件格式,而我使用的源不符合这种格式的某些标准。我认为调整 gem 会比尝试修复文件更容易) 。我认为我所做的改变对大多数其他人来说没有任何用处,所以我不打算分叉该项目。
我想做的是将一个子模块添加到我的 gem 项目的项目中,然后在那里进行更改。我不打算将任何这些更改推送到单独的存储库,但我认为如果他们添加了任何额外的内容,能够将 gem 作者所做的任何更改合并到我的更改中,那就太好了功能。
这看起来合适吗?
I'm fairly new to both Git and Ruby, but I'm wondering if this situation is an appropriate time to use Git submodules, or if I should use a different approach.
I'm working on a Sinatra project. There's a gem I would like to use with the code hosted on Github. I need to make some changes to the gem for my project. (Basically, the gem is for working with a certain file format, and the source I'm using doesn't conform to certain standards for this format. I think it would be easier to adjust the gem rather than try to fix the files). I don't think the changes I'm making would be of any use to most other people, so I wasn't planning on forking the project.
What I was thinking of doing was adding a submodule to my project for the gem project, and then making my changes in there. I don't plan on ever needing to push any of these changes to a separate repository, but I thought it would be nice to be able to pull any changes the authors of the gem make to merge in with my changes if they add any additional functionality.
Does this seem appropriate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这并不完全是子模块的工作方式。您需要某个地方来推送您的更改,否则获取您的存储库的其他人将无法从中提取子模块。您可以在存储主存储库的同一位置创建一个同级存储库,并且可以将其作为子模块的官方源。您仍然可以将上游更改从 gem 拉入您的存储库,只需将生成的合并和更改推送到子模块的远程即可。
That's not quite how submodules work. You need somewhere to push your changes, or anyone else who fetches your repo won't have a place to pull the submodule from. You could just make a sibling repository in the same place your main repo is stored, and you can have that be the official source for the submodule. You can still pull upstream changes from the gem into your repo, you just have to push the resulting merge and changes to your submodule's remote.