Skip to content

Instantly share code, notes, and snippets.

@drench
Created March 23, 2012 16:57
Show Gist options
  • Select an option

  • Save drench/2172756 to your computer and use it in GitHub Desktop.

Select an option

Save drench/2172756 to your computer and use it in GitHub Desktop.
git-rest
#!/bin/sh
case "$1" in
put)
hash=`git hash-object -w --stdin`
if [ -z $2 ]; then
echo $hash
else
git tag $2 $hash
fi
;;
get)
if [ -z $2 ]; then
echo "Missing tagname argument!"
exit 111
fi
git cat-file blob $2
;;
delete)
if [ -z $2 ]; then
echo "Missing object name argument!"
exit 111
fi
git tag -d $2
;;
*)
echo "usage: git rest [put|get|delete] tagname"
;;
esac
@drench
Copy link
Author

drench commented Mar 23, 2012

This is for creating, reading, and destroying arbitrary objects (blobs) in the git filesystem. These objects are not part of any branch or "working tree".

Example:

% echo hello | git rest put greeting
% git rest get greeting
hello
% git rest delete greeting
% git rest get greeting
fatal: Not a valid object name greeting

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