Skip to content

Instantly share code, notes, and snippets.

@tomster
Created January 1, 2011 15:40

Revisions

  1. tomster revised this gist Jan 1, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-dropbox
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    #!/usr/bin/env python
    # encoding: utf-8

    @@ -19,9 +18,10 @@ def main():
    if path.exists(target_path):
    exit("Directory already exists at %s, not touching it!" % target_path)
    mkdir(target_path)
    repo_path = path.abspath('.git')
    whereami = getcwd()
    chdir(target_path)
    symlink(path.abspath('.git'), '.git')
    symlink(repo_path, '.git')
    chdir(whereami)
    print("Created symlink at %s" % target_path)

  2. tomster created this gist Jan 1, 2011.
    29 changes: 29 additions & 0 deletions git-dropbox
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@

    #!/usr/bin/env python
    # encoding: utf-8

    """ Create a symlink of the current .git inside your Dropbox, now all your
    local commits will automatically be backed up to Dropbox (without your dropbox
    being littered with development cruft, like temporary build files)
    """

    from os import getcwd, path, mkdir, symlink, chdir

    DROPBOXREPOBASE=path.expanduser('~/Dropbox/Development/git-repos/')

    def main():
    if not path.exists('.git'):
    exit("No .git found in current directory.")
    parent = path.split(path.abspath('.'))[-1]
    target_path = path.join(DROPBOXREPOBASE, parent)
    if path.exists(target_path):
    exit("Directory already exists at %s, not touching it!" % target_path)
    mkdir(target_path)
    whereami = getcwd()
    chdir(target_path)
    symlink(path.abspath('.git'), '.git')
    chdir(whereami)
    print("Created symlink at %s" % target_path)

    if __name__ == '__main__':
    main()