开发者

How to configure Git for using it with Dropbox?

开发者 https://www.devze.com 2023-01-14 01:39 出处:网络
I have been using git for half a year or so and I don\'t know whether I am using git fully. First of all, I have been experimenting with dropbox and I feel that if I can incorporate it into my work f

I have been using git for half a year or so and I don't know whether I am using git fully.

First of all, I have been experimenting with dropbox and I feel that if I can incorporate it into my work flow, it would be really great since dropbox is pretty convenient.

  1. I have a desktop, and a laptop. Both have dropbox.
  2. I initialized my dropbox repos by doing a git init --bare. And then in my Desktop's post-commit script, I have a git push --mirror dropbox.

This way my desktop and dropbox will always be completely mirrored, which is a good thing.

My real question is: How should I set up my laptop? I have been hearing a few suggestions:

  1. Pull from my desktop, so that my laptop's origin is desktop.
  2. Pull directly from dropbox so that my laptop's origin is dropbox.

I have been doing number 2, and I don't know if I am doing the right thing. My work flow includes:

  1. Everytime I am on my laptop, I do a git pull (since laptop's origin is dropbox and dropbox updates itself)
  2. Then when I check out a branch from dropbox to a local branch.
  3. After I am done with work, I commit.
  4. This is where I am confused: Should I push --mirror to my dropbox repos (my laptop's origin repos) too? I am getting some difficulties in this area: Sometimes dropbox doesn't sync quite well, etc

Currently, doing a git branch -r on my desktop after doing git push --mirror origin on my laptop doesn't show my recently laptop commits. Can someone tell me why?

I mentio开发者_开发知识库ned pulling from my desktop directly because that way I can always initialize the pull and I am 100% confident that the sync is done. With dropbox I can never be 100% sure whether the update has been pushed to the dropbox server


If you want to add an intermediate repo container, Dropbox is fine provided:

  1. You use the git bundle format: it generates a bare repo with only one file (meaning Dropbox is more likely to correctly sync it to any of your computers: it is just about copying one file, not "the whole structure" from which you are not sure you will get everything back).

  2. You are using incremental bundle for each of your saves (again, one file per save, easy to pull from on the other side to get back what has been done).
    Name your increment after the source (laptop or desktop) and with the date.
    Basically, you will pull from any xxx.bundle you haven't pulled yet.

  3. You regularly clean all the intermediate incremental bundles, replacing it with a full bundle from whatever source is the most up-to-date

That model allows for:

  • simple sync process (one or very few files)
  • quick saving process (with incremental bundles)
  • scaling: if there is more than one actor, i.e. if several people are updating the same branch, you can isolate their contributions when pulling from them by referencing their bundles using a different remote name (since each bundle is a bare repo from which you can pull).
0

精彩评论

暂无评论...
验证码 换一张
取 消