I have a local git server running on my NAS and I'm developing on my laptop and workstation, all in my local network. So, if I want to start a project in a new empty repo, I'm following this answer and
cd ${PROJECT}.git; git init --bare
cd ${PROJECT}.git; git init --bare
cd ${PROJECT}; git init
cd ${PROJECT}; git init
git add . ; git commit -m "initial commit" -a
git add . ; git commit -m "initial commit" -a
git remote add origin ssh://${USER}@${REMOTEIP}${PROJECT}.git
git push origin master
rm -rf $PROJECT
And then I can clone the ${PROJECT}.git
repo from other machines. This whole process seems overly complicated. I mean, I scripted it,
HOSTIP=XXX.XXX.XXX.XXX
USER=YYYYY
PROJECT=$1
[[ -z "${PROJECT}" ]] && exit 1
PROJECTNAME=${PROJECT}
PROJECT=$(pwd)/${PROJECT}
# create project and .git folders
mkdir ${PROJECT}
mkdir ${PROJECT}.git
# initialize folders for git
cd ${PROJECT}.git
git init --bare
cd ${PROJECT}
git init
# create initial project directory
echo "#!/bin/bash" > ${PROJECT}/ENV_${PROJECTNAME}.sh
git add .
git commit -m "initial commit" -a
# 'link' to 'remote' .git folder
git remote add origin ssh://${USER}@${HOSTIP}${PROJECT}.git
# push to master
git push origin master
# delete 'project' directory
rm -rf $PROJECT
echo "CREATED PROJECT $PROJECT.git"
echo "Clone with git clone ssh://${USER}@${HOSTIP}${PROJECT}"
exit 0
but still, is this the right way to go about this?
Your process is mostly good but a bit overcomplcated. You don't need a non-bare repository on the NAS, so your workflow should be
cd ${PROJECT}.git; git init --bare
cd ${PROJECT}.git; git init --bare
. ${PROJECT}.git
repo on another machine. This adds the remote to the non-bare repo.cd ${PROJECT}; git init; git remote add origin ssh://${USER}@${HOSTIP}${PROJECT}.git
cd ${PROJECT}; git init; git remote add origin ssh://${USER}@${HOSTIP}${PROJECT}.git
cd ${PROJECT}; git init; git remote add origin ssh://${USER}@${HOSTIP}${PROJECT}.git
. git add . ; git commit -m "initial commit" -a
git add . ; git commit -m "initial commit" -a
git add . ; git commit -m "initial commit" -a
. git push origin master
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.