How to backup a local Git repository?

前端 未结 8 1201
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 08:08

I am using git on a relatively small project and I find that zipping the .git directory\'s contents might be a fine way to back up the project. But this is kind of weird bec

8条回答
  •  情书的邮戳
    2020-11-22 08:42

    came to this question via google.

    Here is what i did in the simplest way.

    git checkout branch_to_clone
    

    then create a new git branch from this branch

    git checkout -b new_cloned_branch
    Switched to branch 'new_cloned_branch'
    

    come back to original branch and continue:

    git checkout branch_to_clone
    

    Assuming you screwed up and need to restore something from backup branch :

    git checkout new_cloned_branch --   #notice the space before and after "--"
    

    Best part if anything is screwed up, you can just delete the source branch and move back to backup branch!!

提交回复
热议问题