How to back up private branches in git

前端 未结 7 2217
遇见更好的自我
遇见更好的自我 2020-12-22 17:52

I have a local branch for day-to-day dev work in git. My workflow is:

  1. Do stuff on local_branch, commit
  2. Fetch origin/master
  3. Rebase local_bran
7条回答
  •  清歌不尽
    2020-12-22 18:22

    I use the --mirror option and push to a personal backup repository:

    Add it as a remote:

    git remote add bak server:/path/to/backup/repo
    

    Do the backup:

    git push --mirror bak
    

    This will automatically make your backup repository look like your active one -- branches will be created, deleted, updated (even forced/non-fastforwards) as needed. You can make an alias for this too:

    git config alias.bak "push --mirror bak"
    

    Then, it's just a matter of running "git bak" when you want to do a backup. You could also throw this into a cron job.

提交回复
热议问题