Skip to content

Instantly share code, notes, and snippets.

@lanefu
Created November 10, 2022 13:37
Show Gist options
  • Save lanefu/44e67e28d21ea9b5abbf747eb0356a6f to your computer and use it in GitHub Desktop.
Save lanefu/44e67e28d21ea9b5abbf747eb0356a6f to your computer and use it in GitHub Desktop.
simple self-hosted git over plain ssh

Sometimes you just need an easy way to have a private git repo. Put it on your favorite VPS, SBC, linux box, etc

creates a folder and git repo via relative path of user directory

GIT_REMOTE_DIR=GIT/hosted/example
GIT_REMOTE_HOST=myhost.example.com
ssh ${GIT_REMOTE_HOST} "mkdir -p ${GIT_REMOTE_DIR} && git init --bare ${GIT_REMOTE_DIR}"
git clone ${GIT_REMOTE_HOST}:${GIT_REMOTE_DIR}

## extra credit
REPO_NAME=$(basename ${GIT_REMOTE_DIR})
pushd ${REPO_NAME}
printf "# ${REPO_NAME}\n\nTODO Write documentation" > README.md
git add README.md
git commit -m 'init repo readme'
git push
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment