Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of how to use Google Cloud Storage with git-annex
# Initialize git and git-annex
$ mkdir annex-gcs-test
$ cd annex-gcs-test/
$ git init
Initialized empty Git repository in /Users/jterrace/annex-gcs-test/.git/
$ git annex init "my machine"
init my machine ok
(Recording state in git...)
# Set up AWS credentials
$ export AWS_ACCESS_KEY_ID="YOUR-KEY"
$ export AWS_SECRET_ACCESS_KEY="YOUR-SECRET"
# Create a remote called "cloud" that goes to Google Cloud Storage
$ git annex initremote cloud type=S3 encryption=none host=storage.googleapis.com port=80 bucket=jterrace-git-annex
initremote cloud (checking bucket...) (creating bucket in US...) ok
(Recording state in git...)
# Create a test file and add it to git annex
$ echo "test" > testfile.txt
$ git annex add testfile.txt
add testfile.txt (checksum...) ok
(Recording state in git...)
$ git commit -a -m "trying test file"
[master (root-commit) 097e0c8] trying test file
1 file changed, 1 insertion(+)
create mode 120000 testfile.txt
# Ship the file off to the cloud
$ git annex move testfile.txt --to cloud
move testfile.txt (checking cloud...) (to cloud...)
ok
(Recording state in git...)
# The local file is now a symlink
$ ls -l
total 8
lrwxr-xr-x 1 jterrace 5001 186 Jan 19 18:24 testfile.txt -> .git/annex/objects/mk/p0/SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2.txt/SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2.txt
# Use gsutil to see what's in my bucket.. cool!
$ gsutil ls -l gs://jterrace-git-annex/**
5 2013-01-20T02:26:35 gs://jterrace-git-annex/SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2.txt
TOTAL: 1 objects, 5 bytes (5.0 B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.