Created
December 14, 2012 20:30
-
-
Save jaqque/4288424 to your computer and use it in GitHub Desktop.
git subcommand to convert a regular repository to a bare repository, suitable for pushing to
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 | |
source="$PWD" | |
target="$PWD.git" | |
# verify we are a git repositoy | |
if [ ! -d "$source/.git" ]; then | |
echo 'No git repository found.' 1>&2 | |
exit 1 | |
fi | |
# verify we have a place to put the new, bare repository | |
if [ -e "$target" ]; then | |
echo "$target exists" 1>&2 | |
exit 1 | |
fi | |
# verify that repo and index is clean | |
number_of_dirty_files=`git status --porcelain | wc -l` | |
if [ $number_of_dirty_files -gt 0 ]; then | |
echo "$source has uncomitted changes" 1>&2 | |
exit 1 | |
fi | |
# do it! | |
# move repo/.git to repo.git (proper, bare, naming convention) | |
mv "$source/.git" "$target" | |
# tell git it is a bare repository | |
git config --file="$target/config" --bool core.bare true | |
# remove everything | |
# might be hard to do, since it is a $PWD for the parent process | |
#rm -rf "$source" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment