Skip to content

Instantly share code, notes, and snippets.

@Explorer09
Forked from andris9/git-cache-meta.sh
Last active December 15, 2015 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Explorer09/5331089 to your computer and use it in GitHub Desktop.
Save Explorer09/5331089 to your computer and use it in GitHub Desktop.
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
: ${GIT_CACHE_META_FILE=.git_cache_meta}
if [ -n "$(find -prune -printf '%Tz %Az\n' | tr -d ' 0-9+-')" ]; then
echo "%z not supported in 'strftime' in C library." >&2
exit 1
fi
case $@ in
--store|--stdout)
case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
git ls-files -z | xargs -0 -I NAME find NAME \
\( -printf 'chown -h %U ' -exec ls --quoting-style=shell '{}' \; \) , \
\( -printf 'chgrp -h %G ' -exec ls --quoting-style=shell '{}' \; \) , \
\( \! -type l -printf 'chmod %#m ' -exec ls --quoting-style=shell '{}' \; \) , \
\( -printf 'touch -c -h -m -d "%TY-%Tm-%Td %TH:%TM:%TS %Tz" ' -exec ls --quoting-style=shell '{}' \; \) , \
\( -printf 'touch -c -h -a -d "%AY-%Am-%Ad %AH:%AM:%AS %Az" ' -exec ls --quoting-style=shell '{}' \; \) ;;
--apply) sh -e $GIT_CACHE_META_FILE;;
*) 1>&2 echo "Usage: $0 --store|--stdout|--apply"; exit 1;;
esac

source:

git-cache-meta --store

destination:

git-cache-meta --apply

Download jgit.sh

Config

cat > ~/.jgit
accesskey: aws access key
secretkey: aws secret access key
<Ctrl-D>

Setup repo

git remote add origin amazon-s3://.jgit@bucket.name/repo-name.git

Push

jgit push origin master

Clone

jgit clone amazon-s3://.jgit@bucket.name/repo-name.git

Pull

jgit fetch
git merge origin/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment