Simple Script for Create and Publish a New Git Repository Only With Ssh on Server

| Comments

This simple bash script publish a new git repository on remote server, it script is based you are creating a new git repository.

This script was based on dreamgit.sh from dreamhost wiki.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

# set -x ## debug
SERVER_REPOS="/path/to/repos.git"
LOCAL_REPOS="/path/to/Repositories"
DREAMGIT_DOMAIN=user@host.domain.com


cd $LOCAL_REPOS
ssh $DREAMGIT_DOMAIN 'mkdir -p '$SERVER_REPOS/$1'.git && cd '$SERVER_REPOS/$1'.git && git --bare init'
mkdir $1
cd $1
git init
git remote add origin ssh://$DREAMGIT_DOMAIN$SERVER_REPOS/$1.git
touch .gitignore
git add .
git commit -m 'New repository created'
git push origin master
echo "
[branch \"master\"]
  remote = origin
  merge = refs/heads/master" >>.git/config
echo "New repository '$1' was created and iniatialized on $DREAMGIT_DOMAIN$SERVER_REPOS/$1.git"

Comments