Skip to content

Instantly share code, notes, and snippets.

@eykanal
Created October 31, 2011 21:14
Show Gist options
  • Save eykanal/1328976 to your computer and use it in GitHub Desktop.
Save eykanal/1328976 to your computer and use it in GitHub Desktop.
Create basic .gitconfig file
#!/usr/bin/ruby
if File.exists?(File.expand_path("~/.gitconfig"))
puts "~/.gitconfig file already exists, exiting."
exit false
end
puts '##'
puts '## Git stores each entry with your name, email, and a unique identifier.'
puts '## The following will set up Git with this information, as well as some '
puts '## basic settings to make Git easier to use.'
puts '##'
puts ''
puts "Enter full name:"
full_name = gets.chomp
puts "Enter email address:"
email = gets.chomp
File.open(File.expand_path("~/.gitconfig"), "w") do |f|
f.syswrite("[user]\n")
f.syswrite(" name = #{full_name}\n")
f.syswrite(" email = #{email}\n")
f.syswrite("[color]\n")
f.syswrite(" ui = auto\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment