Skip to content

Instantly share code, notes, and snippets.

@drkvogel
Created October 21, 2019 02:50
Show Gist options
  • Save drkvogel/fd0580cab0bf7019948d9bad229143d2 to your computer and use it in GitHub Desktop.
Save drkvogel/fd0580cab0bf7019948d9bad229143d2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# restore git repo from .dmp file
# What is a .git.dmp file and how can I use it? - Stack Overflow (https://stackoverflow.com/questions/2042429/what-is-a-git-dmp-file-and-how-can-i-use-it/3453461#3453461)
function quit {
echo "quitting"
exit 0
}
function usage {
echo "usage: $(basename $0) <filename>";
echo " unpack git repo from .dmp file";
quit
}
if [ $# != 1 ]; then
usage
fi
if [ ! -f $1 ]; then
echo "no such file: $1"
quit
fi
echo "undump $1"
if [[ "data" -ne $(file -b $1) ]]; then
echo "$1 is not data"
quit
fi
DMPFILENAME=$1
REPONAME=$(echo $1 | cut -d '.' -f 1) # first part of filename e.g. for "flipper.git.dmp" => "flipper"
echo "repo name will be: $REPONAME"
if [ -d $REPONAME ]; then
echo "directory exists: $REPONAME"
quit
fi
mkdir $REPONAME
cd $REPONAME
git init
git fast-import < ../$DMPFILENAME
git checkout master
echo "finished $(basename $0)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment