Created
July 14, 2009 02:36
-
-
Save ericboehs/146661 to your computer and use it in GitHub Desktop.
Init's a git repo on a remote git server and then pushes the current directory to it (not for use w/ github)
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
#!/bin/bash | |
# rgi by Eric Boehs | |
# I like to put this in my ~/bin (which I put in my path) as rgi (remote git initialize) | |
# Specify your remote user@server here | |
[email protected]; | |
# ====================== | |
# = END OF USER CONFIG = | |
# ====================== | |
# Use the current directory for the $dir variable | |
dir=$(basename $(pwd)); | |
# Create the remote directory and do a bare init on it | |
ssh $GIT_DOMAIN 'mkdir -p ~/git/'$dir'.git && cd ~/git/'$dir'.git && git --bare init'; | |
# Do stuff to the local directory | |
git init; | |
# Add the remote repo as origin and also set it to track master (so you don't have to specify anything after your git push command) | |
git remote add -t master origin ssh://$GIT_DOMAIN/~/git/$dir.git; | |
# This is to hide Mac OS X's nasty .DS_Store file | |
echo ".DS_Store" >> .gitignore; | |
# And the rest should be pretty familiar | |
git add .; | |
git commit -m 'Created new repo'; | |
git push origin master; | |
echo "Your new git repo '$dir' is ready and initialized at $GIT_DOMAIN/~/git/$dir.git"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment