# PREP WORK git clone --depth=1 --branch=master https://github.com/frej/fast-export.git curl "http://repo1.maven.org/maven2/com/madgag/bfg/1.12.15/bfg-1.12.15.jar" -o /bfg.jar cp {authors.py,users.csv} mkdir # TO CREATE A GIT REPO AT FROM cd hg log | grep user: | sort | uniq | sed "s/user: *//" > /authors.txt cd python /authors.py cp /* . git init git config core.ignoreCase false ./hg-fast-export.sh -r --force -A reformatted-authors.txt git config --bool core.bare true # WARNING !!! # ----------- # RUNNING HG-FAST-EXPORT AFTER THE FOLLOWING HAVE BEEN DONE IS DIFFICULT. # DO NOT EXECUTE ANY OF THE FOLLOWING UNTIL YOU ARE SURE GIT NO LONGER NEEDS TO SYNC WITH HG!! # TO CLEAN UP LARGE FILES git gc java -jar /bfg.jar --strip-blobs-bigger-than # == ~40M git reflog expire --expire=now --all git gc --prune=now --aggressive # TO DELETE ALL CLOSED BRANCHES cd hg heads --closed --template "{branch}\n" | tr " " "_" | sort > /all.log hg heads --template "{branch}\n" | tr " " "_" | sort > /open.log cd comm -2 -3 all.log open.log > closed.log for branch in `cat closed.log`; do git tag "closed/$branch" $branch; git branch -df $branch; done # TO CONVERT HGIGNORE TO GITIGNORE (do this on a non-bare clone) find . -name ".hgignore" > hgignore-files.log for file in `cat hgignore-files.log`; do newfile=${file/hgignore/gitignore}; echo $newfile >> gitignore-files.log cp $file $newfile; sed -i.bak "s/syntax:/#syntax:/; s/^\^//; s/\$$//; s/\\\w\+/*/; s/\\\\\//\//g" $newfile; # optional done cat gitignore-files.log | xargs git add git clean -df && git commit -m "Added gitignore files" # CLEANUP rm -rfi * # removes everything except dotfiles!!! # OTHER TASKS * cloning non-bare mirror repo with all branches: git clone --mirror /.git cd git config --local --bool core.bare false git checkout master * cloning repo with a specific : git clone -b --single-branch * serving git repo git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose * URL: git://10.0.33.167/ * convert bare repo to non-bare git config --bool core.bare false git checkout master -f