Skip to content

Instantly share code, notes, and snippets.

@canabady
Last active January 3, 2020 10:11
Show Gist options
  • Save canabady/b8ce22df123d36ce3323008d4f1e0259 to your computer and use it in GitHub Desktop.
Save canabady/b8ce22df123d36ce3323008d4f1e0259 to your computer and use it in GitHub Desktop.
organizing myfiles
<title>organizing myfiles</title>

Organizing the working directory

Step-1:

  • Create gitlab account for the year. Other options are github, bitbucket etc.,

  • Now we start with current year i.e. say 2020, then create a repository named 2020 preferably in gitlab.

  • Clone this repository to the local home directory

  • For each folder we need inside 2020, create a git repo in remote and then add it to local 2020 repo as submodule.

    Suppose if you want a folder named dev in 2020. Then create a remote repo for dev and add it to local 2020 as submodule
    [master] ~/2020 $ git submodule add dev

    Note: For every commit in submodule, you have to make a commit in main git i.e. 2020 so that it will point to lastest commit for corresponding submodule.

  • If you need encrypted repository for personal information, then you can try git-remote-gcrypt.
    Say for a repository personal, you need encrypted repository, then create personal repository in remote. Add it as submodule in local repository. Then create a gitcrypt remote inside local personal folder.

    git remote add gitcrypt gcrypt::git@gitlab.com:ACCOUNT_NAME/personal.git#next

    git config remote.gitcrypt.gcrypt-participants "<gpg-key-id>"

    Also add GPG Keys in gitlab account settings.
    For more details refer Encrypted Git remotes with git-remote-gcrypt

Step-2:

  • Create a goggle drive account and add a folder named 2020 into it.

  • Configure rclone for access to this remote 2020. For this your need to make an oAuth2 connection with client_id and client_secret creation in google developer console.

  • Create a mirror folder like $HOME/gcloud/2020 for rsyncing 2020 to it. We can exclude .git, .swp etc., in rsync.
    rsync -avz --exclude '.git' --exclude '.trash' --exclude '.*.swp' --exclude 'plugins' --exclude 'python2.7' --exclude 'lib' --exclude 'python3.5' --exclude 'python3.5' $HOME/2020/. $HOME/gcloud/2020/

  • Sync the mirror 2020 folder to google drive using rclone copy. A crontab entry can do regular sync.
    rclone copy $HOME/gcloud/2020 remote2020: -v

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment