Effectively use Git and Dropbox at the same time?

Posted by Hitoshi on Wed, 11 Dec 2019 19:35:10 +0100

How to use them together effectively Git and Dropbox

#1 building

I ran into a similar problem and created a small script for it. The idea is to use Dropbox with Git as simply as possible. At present, I have realized it quickly Ruby Code, and I'll add more code soon.

The script is available at https://github.com/nuttylabs/box-git.

#2 building

For small teams using Dropbox:

If each developer has its own writable bare repository on Dropbox (which can only be dragged to other developers), this will promote code sharing without damage!

Then, if you want a centralized "mainline," you can have a developer manage all the push to it from their own repository.

#3 building

I think Git on Dropbox is great. I've been using it. I have multiple computers (two at home and one at work), and I use Dropbox as a central bare warehouse. Because I don't want to host it on a public service, and I can't access servers that I can always ssh to, Dropbox solves this problem by syncing (very fast) in the background.

The setup is as follows:

~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git

~/Dropbox/git $ git init --bare project.git
~/Dropbox/git $ cd ~/project

~/project $ git remote add origin ~/Dropbox/git/project.git
~/project $ git push -u origin master

From there, you can clone ~ / Dropbox/git/project.git associated with your Dropbox account (or share this directory with others), you can perform all normal Git operations, and they will be synchronized to all your other machines automatically.

I wrote an article About version control Blog post for( Old link already Failure), which introduces my reasoning and how to set up the environment, based on my On Ruby on Rails Development experience, but it can actually be applied to anything.

#4 building

I like the answer Dan McNevin voted the most. I finally executed the git command sequence many times and decided to make a script. So here is:

#!/bin/bash

# Usage
usage() {
    echo "Usage: ${0} -m [ master-branch-directory ] -r [ remote-branch-directory ] [ project-name ]"
    exit 1
}

# Defaults
defaults() {
    masterdir="${HOME}/Dropbox/git"
    remotedir="${PWD}"
    gitignorefile="# OS generated files #\n\n.DS_Store\n.DS_Store?\n.Spotlight-V100\n.Trashes\nehthumbs.db\nThumbs.db"
}

# Check if no arguments
if [ ${#} -eq 0 ] ; then
    echo "Error: No arguments specified"
    usage
fi

#Set defaults
defaults

# Parse arguments
while [ ${#} -ge 1 ]; do
    case "${1}" in
        '-h' | '--help' ) usage ;;
        '-m' )
            shift
            masterdir="${1}"
            ;;
        '-r' )
            shift
            remotedir="${1}"
            ;;
        * )
            projectname="${1##*/}"
            projectname="${projectname%.git}.git"
            ;;
    esac
    shift
done

# check if specified directories and project name exists
if [ -z "${projectname}" ]; then
    echo "Error: Project name not specified"
    usage
fi

if [ ! -d "${remotedir}" ]; then
    echo "Error: Remote directory ${remotedir} does not exist"
    usage
fi

if [ ! -d "${masterdir}" ]; then
    echo "Error: Master directory ${masterdir} does not exist"
    usage
fi

#absolute paths
remotedir="`( cd \"${remotedir}\" && pwd )`"
masterdir="`( cd \"${masterdir}\" && pwd )`"

#Make master git repository
cd "${masterdir}"
git init --bare "${projectname}"

#make local repository and push to master
cd "${remotedir}"
echo -e "${gitignorefile}" > .gitignore # default .gitignore file
git init
git add .
git commit -m "first commit"
git remote add origin "${masterdir}/${projectname}"
git push -u origin master

#done
echo "----- Locations -----"
echo "Remote branch location: ${remotedir}"
echo "Master branch location: ${masterdir}"
echo "Project Name: ${projectname}"

The script requires only one project name. It will generate a git repository at ~ / Dropbox/git / with the specified name, and push the entire contents of the current directory to the newly created origin master branch. If more than one project name is given, the rightmost project name parameter is used.

(optional) - r command parameter specifies the remote branch that will be pushed to the original host. You can also use the - m parameter to specify the location of the project's original master file. The default. gitignore file is also placed in the remote branch directory. Specify the default values for the directory and. gitignore file in the script.

#5 building

I use Mercurial (or Git) + TrueCrypt + Dropbox for encrypted remote backups.

The cool thing is that if you modify a small part of your code, Dropbox won't sync the entire TrueCrypt container. The synchronization time is approximately proportional to the amount of change. Even if encrypted, the combination of TrueCrypt + Dropbox can make good use of block cipher + block level synchronization.

Second, integrated encryption containers not only increase security, but also reduce the number of repositories Damaged Opportunity.

Warning: however, you must be very careful not to install containers when running Dropbox. Resolving conflicts can also be painful if two different clients check different versions into the container. As a result, it's only useful for individuals who use backup for backup, not for teams.

Set up:

  • Create a Truecrypt container (multiple gigabytes will do)
  • Under Truecrypt preferences, uncheck preserve modification timestamp *.
  • Like Dan above( https://stackoverflow.com/a/1961515/781695 )Create a warehouse as described in

Usage:

  • Exit Dropbox
  • Install container, push your changes, remove
  • Operation drop box

PS unchecks preserve modification timestamp to notify Dropbox that the file has been modified and should be synchronized. Note that even if you do not change any of these files, the installation container modifies the timestamp. If you don't want this to happen, simply mount the volume as read-only

Topics: git Ruby github ssh