Skip to content

Instantly share code, notes, and snippets.

@madcato
Created May 4, 2019 09:46
Show Gist options
  • Save madcato/0d167447569f39808b2f06621601420a to your computer and use it in GitHub Desktop.
Save madcato/0d167447569f39808b2f06621601420a to your computer and use it in GitHub Desktop.
Backup each project by cloning all their repositories: clone the main repo and also the wiki repo
#!/usr/bin/env ruby
# Backup each project by cloning all their repositories: clone the main repo and also the wiki repo.
#
# git clone [email protected]:ai/AAI.git
#
# The clone must be done only once. After that use ```git fetch --all``` to refresh all data
#
# - [doc](https://stackoverflow.com/questions/67699/how-to-clone-all-remote-branches-in-git)
#
repos = ['[email protected]:ai/AAI.git',
'[email protected]:ai/AAI.wiki.git',
'[email protected]:PracticeEnglishApp/marla.git',
'[email protected]:PracticeEnglishApp/marla.wiki.git']
if ARGV[0] == '?'
puts("")
puts("Execute 'backgit install' to create clones ")
puts("After that, execute 'backgit' without params to update repos")
puts("")
exit
end
if ARGV[0] == "install"
repos.each do |repo|
`git clone #{repo}`
end
else
Dir.glob('*/').each do |cdir|
`cd #{cdir} && git fetch --all && cd ..`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment