Submitted by mikesven on Wed, 05/04/2011 - 09:59
Recently the team I have been working with is starting to expand, and as this happens I have found my self introducing more and more people to the wonderful world of git. In order to try and ease the pain while people are getting used to a new version control system to help with creating new repositories on our server. In the office we are currently using git though webdav for a number of reason I won’t discuss in this post, so you will find that the script below is tailored to a situation where you can directly move a folder from your system to the server using the “mv” command (ie. the webdav directory is mounted in os x). Windows users will need to use this though cygwin. Below is version one of my script, I hope to work on it a bit more in the following days to make it a bit more user friendly. it can be run by opening terming and typing: ./MyScriptName.sh RepoName (replacing MyScriptName.sh with the name of the script, and RepoName with the desired name of your repository)
#!/bin/bash #variables to change #http path to your webdav folder eg. http://git.mydomain.com/repos/ GIT_SERVER="" #relative path to your webdav folder eg. /Volumes/repos WEB_DAV_DIRECTORY="/Volumes/proj_repos" #DO NOT EDIT PAST THIS POINT #variables set by parameters REPO_NAME="$1" TEMP_REPO_NAME="temp_repo" #start of the script mkdir $REPO_NAME cd $REPO_NAME git --bare init-db git repo-config remote.origin.url "$GIT_SERVER$REPO_NAME" git update-server-info echo "repo created, moving to server" cd "../" mv "$PWD/$REPO_NAME" "$WEB_DAV_DIRECTORY" mkdir "$TEMP_REPO_NAME" cd "$TEMP_REPO_NAME" touch "README" git init git add . git commit -m "Initial commit, from creation script" git repo-config remote.upload.url "$GIT_SERVER$REPO_NAME" git push upload master cd "../" rm -rf "$TEMP_REPO_NAME" echo "Finished ... Clone your repo to start working"
- mikesven's blog
- Log in to post comments