Skip to content

Instantly share code, notes, and snippets.

@spoterianski
Created December 12, 2011 21:19
Show Gist options
  • Save spoterianski/1469151 to your computer and use it in GitHub Desktop.
Save spoterianski/1469151 to your computer and use it in GitHub Desktop.
Shell script for creating remote repository and link with local
#!/bin/bash
# setup your parameters
ssh_host="yourserver.com"
remote_path="/path_to_git_storage"
# ------------------------------
if [ -z "$1" ]
then
echo "usage: git-remote-init.sh [repository name]"
exit 1
fi
repname=$1
ssh $ssh_host "mkdir -p $remote_path/$repname.git && "\
"git init --bare $remote_path/$repname.git"
reply="N"
read -p "Link current dir to new created repository? (y/N): " reply
if [ "$reply" != "y" ]
then
echo "Exiting..."
exit 1
fi
# init local repository and link to remote
git init
git remote add origin ssh://${ssh_host}$remote_path/$repname.git
touch changelog
git add changelog
git commit -a -m"Initital commit"
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment