How to back up private branches in git

I have a local branch for daily dev work in git. My workflow:

  • Do stuff on local_branch, commit
  • Source / Wizard Selection
  • Rebase local_branch to catch up with new material from source / master

Everything works fine, but most of the recommendations that I met say that you can’t "push" private branches on which the permutation is regularly performed.

The problem is that in this case the local branch is not reserved on the server, and the only way to save work is to merge it back into the "pushable" branch (ie start / wizard)

What will be your recommendations on the workflow in this case?

Thank!

UPDATE . I realized that one of the initial requirements that I used (avoiding the use of external utilities) is not a necessary limitation.

My current solution is to keep all my repositories in a folder with cloud sync - this way I get a free backup.

+43
git workflow merge rebase dropbox
May 29 '09 at 1:01 a.m.
source share
7 answers

I use the -mirror option and click on the personal backup repository:

Add it as remote:

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

Make a backup:

 git push --mirror bak 

This will automatically make your backup repository look like your active one. If necessary, branches will be created, deleted, updated (even forced / not fastforwards). You can also make an alias:

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

Then it’s just a matter of running git bak when you want to back up. You can also drop this to a cron job.

+47
May 30 '09 at 17:26
source share
β€” -

Another option is to push "local_branch" to the "origin" repository, but it has its own branch in this repo (not "master"), that is:

git push origin local_branch:local_backup

Then, when you are ready to make another backup (and after doing some work and rebooting), simply remove the backup branch from the source repo before you pull it out:

git push origin :local_backup <=== removes the branch from the source

git push origin local_branch:local_backup

Thus, you will not encounter problems clicking on "local_branch" after it has been reinstalled from "origin / master".

And if deleting your backup branches makes you nervous (until you finally finish your work with the "master"), you can always continue to click on a new branch with a new name (for example, "local_backup1", "local_backup2" ), etc.).

+4
May 29 '09 at 2:13
source share

There is nothing wrong with pushing personal branches. This is usually discouraged because people can start work based on your branch, and when you reinstall, their changes remain floating.

I use the prefix to mean "this is my branch, use it at your own risk," for example: fc-general-cleanup .

+3
May 29 '09 at 23:11
source share

There is nothing wrong with clicking on the same branch from which you are reinstalling. These diagrams should illustrate why this works great:

Lets say what the fix graph looks like after you branched local_branch and made a couple of attempts (C and D). Someone else made one commit (E) in origin / master, since you forked local_branch:

 A - B - E [origin / master]
       \
        \    
         \ - C - D [local_branch]

Then after running git rebase origin / master, the commit graph will look like this. "origin / master" is still the same, but "local_branch" has been reinstalled:

 A - B - E [origin / master]
            \
             \
              \ - C - D [local_branch]

At this point, if you do git push origin local_branch: master ", then this will result in a simple fast forward." Origin / master "and" local_branch "will be identical:

 A - B - E - C - D [origin / master], [local_branch]

Now you can work more on "local_branch". In the end, you can get something like this:

 A - B - E - C - D - G - I [origin / master]
                      \
                       \
                        \ - F - H [local_branch]

Please note that this is very similar to the initial chart. You can continue to repeat this process over and over.

You should avoid clicking on another branch from which you are not reinstalling. This is where you run into trouble (to another branch, it will look like your "local_branch" story was suddenly rewritten after you reinstalled it from "origin / master").

+2
May 29 '09 at 1:38
source share

Can you set up another remote repository that you push all your branches to? Another thing worth considering is to simply back up everything (important) on your local machine, including git repo.

+1
May 29 '09 at 1:09 a.m.
source share

Here is what I am doing . But - this is not personal. I do it so that I can collaborate with myself (so to speak). This allows me to work in the same branch on two or more mailboxes. if other people had access to a shared repo, they could see the work I do at the branch. Of course, no one has access to my home repository, so it's still private. On github, the whole world could see my things. As if they really care .;)

+1
May 29 '09 at 2:01 a.m.
source share

Instead of relying on Dropbox to sync all the files in the git repository, I would rather use a git bundle , which produces only one file (including all your private branches) and synchronizes this file with DropBox.
See " Git with Dropbox "

Under Backing up local git storage , Yars mentions the presence of synchronization errors with Dropbox.

0
Sep 05 '12 at 7:50
source share



All Articles