Created
August 8, 2014 20:48
-
-
Save Tantas/587ed9bebb634895d236 to your computer and use it in GitHub Desktop.
Migrates a local git repository to the gitolite server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Migrates from a local git project and places onto the gitolite server. | |
# Reference http://gitolite.com/gitolite/g2/moverepos.html | |
# Usage: Execute from the git directory to migrate | |
# ex. ~/Developer/gitolite/migrate_repo.sh new-repo-name | |
# Get the current working directory | |
EXISTING_REPO_DIRECTORY=$(pwd) | |
# Configure the variable to the gitolite-admin directory | |
GITOLITE_ADMIN_DIR=${0%/*} | |
# The argument is the new project name on the remote server | |
if [[ -z $1 ]]; then | |
echo "Must provide the new name of the project as an argument." | |
echo "Must be a valid repository name." | |
echo "Do not include the .git file suffix." | |
exit -1 | |
fi | |
# Create the new gitolite project, add to all users | |
GITOLITE_CONFIG="${GITOLITE_ADMIN_DIR}/conf/gitolite.conf" | |
echo -e "\nrepo $1" >> "${GITOLITE_CONFIG}" | |
echo -e " RW+ = @all\n\n" >> "${GITOLITE_CONFIG}" | |
cd "${GITOLITE_ADMIN_DIR}" | |
git add * | |
git commit -m "Adding project $1" | |
git push | |
# Return to the existing repository | |
cd "${EXISTING_REPO_DIRECTORY}" | |
##Note*: privategit is an ssh alias | |
#host privatessh | |
# user git | |
# hostname xxx.xxx.xxx.xxx | |
# port 22 | |
# identityfile ~/.ssh/privateKey | |
# Move an existing repository to the gitolite server | |
git push --all "ssh://privategit/$1" | |
git push --tags "ssh://privategit/$1" | |
# Use git push --mirror instead if want to carry accross remote refs | |
# Verify Creation | |
git ls-remote "ssh://privategit/$1" | |
# Remember to update the permissions manually after | |
# vim conf/gitolite.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Place in your gitolite admin directory | |
# Configure the variable to the gitolite-admin directory | |
GITOLITE_ADMIN_DIR=${0%/*} | |
if [[ -z $1 ]]; then | |
echo "Provide the git commit as the argument!" | |
exit -1 | |
fi | |
# Change directory to where the git repository is | |
cd "${GITOLITE_ADMIN_DIR}" | |
# Commit all files and push to the server. | |
git add * | |
git commit -m "$1" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment