Created
September 22, 2011 23:27
-
-
Save buritica/1236337 to your computer and use it in GitHub Desktop.
Create new folder, init repo, add readme.md, add remote origin, first commit, push to origin
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 | |
# USAGE: sudo ./newrepo.rb folder_name origin_url | |
# Give it exec permissions before running: chmod +x init.rb | |
# Protip: add it to your ~/.profile or ~/.bash_profile, copy it to your ~/Scripts and run it from anywhere: | |
# alias new_repo="~/Scripts/new_repo.rb" | |
require 'fileutils' | |
if ARGV[0].nil? or ARGV[1].nil? then | |
puts "Usage: ./newrepo.rb <folder_name> <origin_url>" | |
exit | |
end | |
folder_name = ARGV[0] | |
origin_url = ARGV[1] | |
FileUtils.mkdir_p("#{folder_name}") | |
puts "initializing repo..." | |
FileUtils.cd("#{folder_name}", :verbose => true) | |
`git init` | |
puts "adding readme.md and commiting..." | |
FileUtils.touch("readme.md") | |
`git add .` | |
`git commit -m 'first commit'` | |
puts "adding origin and pushing master..." | |
`git remote add origin #{origin_url}` | |
%x(git push origin master) | |
puts "repo created successfully ;)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment