rileyrg / resgithub

Reset local repo as if newly born. Push as new to github. Remote branches are maintained.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reset local repo as if newly born. Push as new to github. Remote branches are maintained.

Note this does NOT remove remote branches.

ALL history AND local branches will be lost but your .git/config, .git/info/exclude and .gitignore will be maintained.

#!/usr/bin/bash
#Maintained in resgithub.org
tconfig=$(mktemp)
texclude=$(mktemp)
commitmsg=${1:-"git repository initialised"}
if [ -f .git/config ]; then
    cp .git/config "$tconfig"
    cp .git/info/exclude "$texclude"
    rm -rf .git
    git init .
    mv "$tconfig" .git/config
    mv "$texclude" .git/info/exclude
    git add .
    git commit -a -m "$commitmsg"
    git push -f
else
    echo "test Warning: No git config file found. Aborting.";exit;
fi

Tasks

TODO [#A] dont do anything if it's a bare repo as everything will be gone!

TODO [#C] remove github references as is generic to all origins

About

Reset local repo as if newly born. Push as new to github. Remote branches are maintained.


Languages

Language:Shell 100.0%