Skip to content

Instantly share code, notes, and snippets.

@h4de5
Created February 18, 2020 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h4de5/bc34af1c822c9dbe6cf10a73c919cff8 to your computer and use it in GitHub Desktop.
Save h4de5/bc34af1c822c9dbe6cf10a73c919cff8 to your computer and use it in GitHub Desktop.
Create a bare git repository which allows pushing from other users of the same user group.
#!/bin/bash
# usage ./create_bare_git.sh ProjectName
git init --bare --shared=group "$1.git"
LAST_USERGROUP=`groups | awk '{ print $NF }'`
# CURRENT_DIR=`pwd`
CURRENT_DIR=`realpath .`
chgrp -R $LAST_USERGROUP "$1.git"
echo "use this to set remote the first time:"
echo
echo "git remote add origin `hostname -f`:$CURRENT_DIR/$1.git"
echo "git push --set-upstream origin master"
echo "use this to change the remote of an existing project:"
echo
echo "git remote set-url origin `hostname -f`:$CURRENT_DIR/$1.git"
echo "git push --set-upstream origin master"
echo "use this to checkout the new repository:"
echo
echo "git clone `hostname -f`:$CURRENT_DIR/$1.git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment