Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

git - Using Dropbox to synchronize files and having them backed up in version control

I'm using dropbox for random text notes (org-mode) and dot files that I bootstrap, namely

  1. part of my bash initialization
  2. emacs configuration
  3. vim configuration

Org-mode documentation suggests some backup in case of a mistake in editing folded sections. Makes sense. I also want backups in case I want to back out configuration change.

There are tons of postings on why using git can break in dropbox.

I see a few options:

  1. Not use dropbox and use bitbucket to host the files on git. The disadvantage is that when I switch machines, I have to remember to pull any changes, which is not convenient.

  2. I can use git via a chron job on one of my machines to backup the files in the dropbox folder and make sure that the git directory is not sync'd by dropbox. The disadvantage would be that this is a little asymetrical in that one machine has git on the dropbox files . However, the history is just for backup purposes rather than collaboration purposes.

  3. Not worry about the dropbox issues, as I infrequently commit changes and hardly do any other commands with the git repositories.

  4. Maybe a combination of #1 and #2. Occasionally push my changes to remote, having the .git directory not sync'd.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use dropbox, just not for a full bare Git repo (because of the high number of files to synchronize and the risk for a corrupted repo if even one of those file doesn't get sync properly, as shown in "Git ref master now empty, how to recover?").

I prefer to use dropbox in conjunction with a git repo bundle (ie one file):
See "Git with Dropbox" and "Backup a Local Git Repository".
See a detailed analysis in this blog post.

You can see an example of a script for that kind of task here (example by shtirlic (Serg Podtynnyi)):

#!/usr/bin/env ruby
if __FILE__ == $0
        bundle_name = ARGV[0] if (ARGV[0])
        bundle_name = `pwd`.split('/').last.chomp if bundle_name.nil?
        bundle_name += ".git.bundle"
        puts "Backing up to bundle #{bundle_name}"
        `git bundle create ~/Dropbox/backup/git-repos/#{bundle_name} --all`
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...