Created
May 4, 2019 09:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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