Blog
arrow
2017-10-06 14:44
Script for creating a git repository on the server

This script creates a new directory, inits an empty git repository and suggests commands for configuring push from a local repository.

#!/bin/bash

set -e

if [[ $# -eq 0 ]] ; then
  echo "Usage:"
  echo "$0 path-to-new-dir"
  exit 1
fi

mkdir "$1"
git init --bare "$1"

echo "Run these commands in the local repository:"
echo
echo "git remote add origin ssh://$USER@`hostname``readlink -f "$1"`"
echo "git push --set-upstream origin master"

Up