Skip to content

Instantly share code, notes, and snippets.

@feythin
Forked from mike-zhang/git_Backup.py
Created November 30, 2012 12:46
Show Gist options
  • Save feythin/4175551 to your computer and use it in GitHub Desktop.
Save feythin/4175551 to your computer and use it in GitHub Desktop.
git备份程序
import os
'''
.ssh/config (windows):
Host host100
Hostname 192.168.1.100
User git
IdentityFile C:/Users/admin/.ssh/id_rsa_gitBackup_host100
repo example:
/home/git/test1.git
'''
hostName = "host100"
dirs = [
'test1',
'test2'
]
for dirName in dirs:
print dirName," : ",
if os.path.exists(dirName):
print "exists"
strCmd = "cd %s && git pull && cd .." % dirName
print strCmd
os.system(strCmd)
else:
print "not exists"
strCmd = "git clone %s:%s.git " % (hostName,dirName)
os.system(strCmd)
raw_input("Press Enter to continue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment