gpt4 book ai didi

git - 如何自动将 Remote 添加到 Git 存储库?

转载 作者:太空狗 更新时间:2023-10-29 14:19:55 24 4
gpt4 key购买 nike

我们的团队最近一直在增加新成员。每次我们添加新人时,他们都会获得自己的远程 Git 存储库。每个项目的 .git/config 中的 Remote 数量增加一个。团队中的每个人都需要将新 Remote 添加到每个项目中。新人在最初克隆项目时必须为每个现有团队成员添加 Remote 。

这很烦人。有没有什么方法可以自动将所有合适的 Remote 添加到所有项目以消除这种麻烦?

最佳答案

只需编写一个 shell 脚本来确保所有远程都存在,然后通过将其 checkin 存储库或使其在带外可用来与团队共享。

如果你愿意,你可以重用some shell functions which I already wrote for managing git remotes ,例如:

# clone the above repo to some $MR_CONFIG_REPO first
source $MR_CONFIG_REPO/sh.d/git-remotes
for developer in alice bob charles dave; do
git_add_remote $developer https://github.com/$developer/$PROJECT_NAME.git
done

# or if the repo URLs don't follow a pattern
git_add_remotes "
alice https://github.com/alice/$PROJECT_NAME.git
bob https://src.bob.com/git/$PROJECT_NAME.git
charles file:///mnt/nfs/git/$PROJECT_NAME.git
dave git@github.com:dave/${PROJECT_NAME}-2.git
"

如果你想变得更复杂,你可以从我的mr configuration repository中窃取更多的想法。 , 特别是 this file . mr是一个非常方便的存储库批量管理工具,我已经广泛使用它很长时间了。

关于git - 如何自动将 Remote 添加到 Git 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19161848/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com