通过克隆/推/拉传播远程位置 [英] Propagate a remote location via clone/push/pull
问题描述
我们的项目使用了多个第三方开源库,其中一些需要自定义修改。
对于每个库我们创建了自己的本地git仓库,添加了原始源位置作为供应商远程,从那里克隆,根据需要进行修改并将其推送到内部远程存储库(我们称之为 origin )。 b
$ b
这些存储库在我们的核心项目中用作子模块。
问题:
vendor remote url不会传播到origin,因此会被任何克隆内部库存储库的人丢失。
每次要合并库的新上游更改时,都需要再次找到并手动添加供应商远程设备(或者在开始时使用完全相同的本地存储库(如果它仍然可用) 。
有没有更好的方法来存储供应商存储库网址,以便它可以b e是否被每个开发者传播和使用?向库中添加一个额外的文件(例如 clone_from_here
)看起来并不是很优雅。
您可以通过 .git / config
来完成。在您成功提取或推送更改后,查看 .git / config
文件并记录远程 url
和 fetch
在您的开发人员克隆存储库之后,打开 .git / config
,然后添加你复制的行。示例 -
[remotevendor]
url = git@xxx.com:xxxxx / xxxxxxx.git
fetch = + refs / heads / *:refs / remotes / origin / *
现在可以在这个例子中推送或拉到供应商。
如果您需要更多的控制来编写提取网址 - 在gitguys上有很好的文档 - http://goo.gl/JGaKD
Our project uses several third-party open-source libraries, some of which require custom modifications.
For each library we created our own local git repository, added the original source location as a vendor remote, cloned from there, modified it as needed and pushed it to an internal remote repository (let's call it origin).
These repositories are then used as submodules in our core project.
The problem: The "vendor" remote url is not propagated to the "origin" and is therefore lost to anyone who clones the internal library repository.
Every time you want to merge the new upstream changes for a library, you need to find and manually add the vendor remote again (or use the exact same local repository created at the beginning, if it's still available).
Is there a better way to store the vendor repository url so that it can be propagated and used by every developer? Adding an extra file (e.g. clone_from_here
) to the library doesn't seem very elegant, either.
You can do it via .git/config
. After you have successfully pulled or pushed your change, look at the .git/config
file and make a note of the remote url
and fetch
After the repository has been cloned by your developer(s), open up .git/config
on the developers machine and add the line you have copied. Example -
[remote "vendor"]
url = git@xxx.com:xxxxx/xxxxxxx.git
fetch = +refs/heads/*:refs/remotes/origin/*
Your developers can now push or pull to vendor in this example.
If you need more control on writing the fetch url - there is excellent documentation on this at gitguys - http://goo.gl/JGaKD
这篇关于通过克隆/推/拉传播远程位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!