Public
Snippet $1655154 authored by Varga Vince

Initialize GitLab repository

init-gitlab-repo.sh
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

usage() {
	printf "\ninit-gitlab-repo - Initialize new repository on GitLab.\n\n * usage: init-gitlab-repo USERNAME REPOSITORY\n   The description of the repository will be asked while the script runs.\n\n"
}

if [[ $# -ne 2 ]]; then
	usage
	exit 1
fi

username=$1
repository=$2
read -p "Please enter the description of the repository: " description

printf "\nCreate new repository \n\t'%s/%s'\nwith user\n\t'%s' <%s>\nRepository description\n\t%s\n\n" $username $repository "$(git config user.name)" "$(git config user.email)" "$description"

git clone git@gitlab.com:$username/$repository.git
cd $repository
echo $description > README.md
git add README.md
git commit -m "Initialize repository"
git push -u origin master