Last active
April 26, 2020 09:29
-
-
Save madcato/f3c1e53743c03c65ed153d94f14d1290 to your computer and use it in GitHub Desktop.
From an existing git repo, create a bare git repository on a remote server and configure its remote.
This file contains 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 | |
begin | |
project = ARGV[0] | |
server = ARGV[1] | |
if project.nil? | |
raise "<project> not specified" | |
end | |
if server.nil? | |
raise "<server> not specified" | |
end | |
`git clone --bare ./#{project} #{project}.git` | |
`scp -r #{project}.git #{server}:#{project}.git` | |
`rm -rf #{project}.git` | |
`cd #{project} && git remote add origin #{server}:#{project}.git && git push --set-upstream origin master` | |
rescue StandardError => e | |
STDERR.puts("Error #{e.message}. Usage: remotize.rb <project> <server>") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage: (from parent directory of git repo named pytorch_test)
remotize.rb pytorch_test [email protected]