How do I convert simple non source controlled project backups into a versioned git repository?

前端 未结 5 758
孤独总比滥情好
孤独总比滥情好 2021-01-04 22:15

I have been extremely naughty. I have been developing a piece of software (I\'m the only developer) for a little while (O.K., it\'s over the course of a few years), but have

5条回答
  •  情书的邮戳
    2021-01-04 22:47

    There might be an already automated way of doing this, but git should be smart enough to let you git init in your oldest backup and then repeatedly copy the .git folder to incrementally newer backups and create a commit with everything for each one. Scripting this should be pretty easy.

    Even better, you could pass a --git-dir= option or $GIT_DIR environment variable to git and have it use a repository, saving the copying step.

    Something like this:

    cd $FINAL_DIR
    git init
    
    export GIT_DIR=$FINAL_DIR/.git
    
    cd $NEXT_BACKUP
    git add -A .
    git commit
    # rinse and repeat
    

提交回复
热议问题