Created
December 12, 2011 21:19
-
-
Save spoterianski/1469151 to your computer and use it in GitHub Desktop.
Shell script for creating remote repository and link with local
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 | |
# 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