kdgwill
kdgwill

Reputation: 2199

Git: All Branches to separate folders

A few years back when I was abandoning an old desktop and converting from cvs/svn to git, which I knew little about, I decided for some odd reason to store all of the projects I would never revisit again into separate branches named after the project; I also put all of the downloadable files in the master branch.

Now I would like to fix this issue and simply have each branch saved as a separate folder in the master branch. I'm guessing the solution is a simple bash script; however, I am not quite sure. Is their a simple way to perform this?

Upvotes: 0

Views: 141

Answers (1)

Norwæ
Norwæ

Reputation: 1575

Something along these lines might help

BRANCHES=$(git branch -a | cut -c 3- | grep -v "master")
for BRANCH in $BRANCHES
do
    git checkout $BRANCH
    CONTENTS=$(ls)
    mkdir $BRANCH
    mv $CONTENTS $BRANCH
    git add -A
    git commit -m "Integrated $BRANCH"
    git checkout master
    git merge $BRANCH
done

Upvotes: 1

Related Questions