How to back up private branches in git

前端 未结 7 2174
遇见更好的自我
遇见更好的自我 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条回答
  •  旧时难觅i
    2020-12-22 18:13

    Another option would be to push "local_branch" to the "origin" repo, but to it's own branch in that repo (not "master"), i.e.:

    git push origin local_branch:local_backup

    Then when you are ready to make another backup (and after you've been doing some work and rebasing) just delete the backup branch from the origin repo before you push it out again:

    git push origin :local_backup <=== deletes the branch from origin

    git push origin local_branch:local_backup

    This way you won't run into problems pushing "local_branch" after it has been rebased from "origin/master".

    And if deleting your backup branches makes you nervous (until after you've finally committed your work to "master"), you could always keep pushing to a new branch with a new name (e.g. "local_backup1", "local_backup2", etc).

提交回复
热议问题