gpt4 book ai didi

ruby - Git 使用脚本(ruby?) pull 多个本地存储库

转载 作者:太空宇宙 更新时间:2023-11-03 17:03:56 25 4
gpt4 key购买 nike

我有大约 30 个从 github 克隆的 git 存储库,用于 web/ruby/javascript 开发。是否可以使用脚本批量更新所有这些?

我把所有东西都组织得井井有条(文件夹结构):

- Workspace
- Android
- Chrome
- GitClones
- Bootstrap
~ etc...30 some repositories
- iPhone
- osx
- WebDev

我有一个用 octokit 克隆存储库的 ruby​​ 脚本,但是对于如何在 GitClones 下的所有存储库中执行 git pull(覆盖/ rebase 本地)有什么建议吗>?

通常,每当我要使用那个 repo 时,我都会 pull ,但我要去一个互联网连接有时才可用的地方。因此,我想在有互联网的情况下更新所有内容。

谢谢! (运行 osx 10.8.2)

最佳答案

如果您必须在 Ruby 中完成,这里有一个快速但肮脏的脚本:

#!/usr/bin/env ruby

Dir.entries('./').select do |entry|
next if %w{. .. ,,}.include? entry
if File.directory? File.join('./', entry)
cmd = "cd #{entry} && git pull"
`#{cmd}`
end
end

不要忘记 chmod +x 您将其复制到的文件,并确保它在您的 GitClones 目录中。

关于ruby - Git 使用脚本(ruby?) pull 多个本地存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13573708/

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