0%

dropbox的使用技巧

没有比数据安全更重要的花费了,一年100刀,也值!

1. dropbox设置为 git远程仓库

1.1 git bare【不安全】

1
2
3
4
5
6
7
8
9
10
~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git

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

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

另外一个电脑操作

1
git clone ~/Dropbox/git/bare.git project2
iShot_2023-02-10_16.47.54

1.2 git-remote-dropbox

项目: https://github.com/anishathalye/git-remote-dropbox

  • 安装

    1
    2
    pip3 install git-remote-dropbox
    export PATH=${HOME}/Library/Python/3.8/bin:$PATH
  • 登录

    1
    2
    3
    4
    git dropbox login

    # 输入密钥
    Successfully logged in! You can now add Dropbox remotes like 'dropbox:///path/to/repo'
  • 操作

    第一个电脑

    1
    2
    3
    4
    git remote rm origin

    git remote add origin "dropbox:///5_Git/project.git"
    git push --set-upstream origin main
    image-20230210163122063

​ 第二个电脑

1
git clone  "dropbox:///5_Git/project.git" project2

  • 还原数据

    1
    2
    3
    4
    5
    mkdir new && cd new 
    git init

    rm -rf .git/{refs,objects} && cp -r ~/Dropbox/5_Git/project.git/{refs,objects} .git/
    git checkout -f main
    image-20230210170204297

2. git 和 dropbox的结合

目前采取危险方案,把 .git 文件夹 同步到 dropbox里面。

3. 本地文件夹同步dropbox【废弃】

还是打开Mac的下载文件夹同步,简直不要太好用。另外可以仿照Mac同步,加入电脑下其他文件夹。

1
2
3
ln -s /Users/liuwei/Dropbox/Mac/workspace ~/workspace
chmod -h 700 ~/workspace
chflags -h uchg ~/workspace
给作者打赏,可以加首页微信,咨询作者相关问题!