Skip to content

Instantly share code, notes, and snippets.

@madcato
Last active April 26, 2020 09:29
Show Gist options
  • Save madcato/f3c1e53743c03c65ed153d94f14d1290 to your computer and use it in GitHub Desktop.
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.
#!/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
@madcato
Copy link
Author

madcato commented Apr 26, 2020

Sample usage: (from parent directory of git repo named pytorch_test)

remotize.rb pytorch_test [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment