* git-attic
@ 2008-07-29 11:57 Paul Gideon Dann
2008-07-29 16:51 ` git-attic Eric Raible
0 siblings, 1 reply; 2+ messages in thread
From: Paul Gideon Dann @ 2008-07-29 11:57 UTC (permalink / raw)
To: git
Hello all,
I looked around everywhere for a script that could make it easy for me
to store stale branches in refs/attic for possible later retrieval. I
don't like such branches lying around in refs/heads and used to tag them
to clear them out of the way, but then that makes "git push origin
--tags" unusable, since I don't want to push my stale branches out...
Anyway, I wrote my own little script in the end and thought it might be
useful to others.
Please Cc pdgiddie@gmail.com in replies,
Paul Gideon Dann
Usage: git-attic
git-attic store <ref> [<commit>]
git-attic remove <ref>
#!/bin/bash
###
# Original Author: Paul Gideon Dann <pdgiddie@gmail.com>
###
showUsage() {
echo "Usage: git-attic"
echo " git-attic store <ref> [<commit>]"
echo " git-attic remove <ref>"
}
case $1 in
"store")
if [[ ! $2 ]]; then
showUsage
exit 1
fi
if [[ $3 ]]; then
OBJECT_SHA1=`git-rev-parse --revs-only $3`
if [[ ! $OBJECT_SHA1 ]]; then
echo "$3 is not a recognisable commit object."
exit 1
fi
else
OBJECT_SHA1=`git show-ref -h HEAD | awk '{print $1}'`
fi
git update-ref refs/attic/$2 $OBJECT_SHA1
echo "$2 stored in attic."
;;
"remove")
if [[ ! $2 ]]; then
showUsage
exit 1
fi
OBJECT_SHA1=`git show-ref attic/$2 | awk '{print $1}'`
if [[ ! $OBJECT_SHA1 ]]; then
echo "$2 does not exist in the attic!"
exit 1
fi
git update-ref -d refs/attic/$2 $OBJECT_SHA1
echo "$2 removed from attic."
;;
*)
if [[ $1 ]]; then
showUsage
else
# display contents of attic
git for-each-ref --format="%(refname)" refs/attic | awk -F /
'{print $3}'
fi
;;
esac
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: git-attic
2008-07-29 11:57 git-attic Paul Gideon Dann
@ 2008-07-29 16:51 ` Eric Raible
0 siblings, 0 replies; 2+ messages in thread
From: Eric Raible @ 2008-07-29 16:51 UTC (permalink / raw)
To: git
Paul Gideon Dann <pdgiddie <at> googlemail.com> writes:
> OBJECT_SHA1=`git show-ref -h HEAD | awk '{print $1}'`
OBJECT_SHA1=`git show-ref --hash --head HEAD`
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-29 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 11:57 git-attic Paul Gideon Dann
2008-07-29 16:51 ` git-attic Eric Raible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).